Write the transition diagram that recognizes the lexemes matching the token Relation Operator(relop) and identifiers.

1. Transition Diagram for Relation Operators (relop)

The token relop stands for relational operators like <, <=, <>, =, >, >=.

Recognized Lexemes: <, <=, <>, =, >, >=

Transition Diagram Description:

We start from state 0, and based on the first input character (<, >, =), the flow moves as shown below:

States marked with * (like 4*, 8*) mean the input must be retracted by one character because that character does not belong to the lexeme.

2. Transition Diagram for Identifiers

An identifier is a name given to variables, functions, arrays, etc.

Recognized Pattern:

  • Starts with a letter (A–Z, a–z)
  • Followed by any number of letters or digits (A–Z, a–z, 0–9)

Leave a Reply

Your email address will not be published. Required fields are marked *