Reorganization of Token

  • Here we address how to recognize token
  • We use the language generated by following grammar,

                 stmt → if expr then stmt

                              | if expr then stmt else stmt

                              | ∈

                expr → term relop term

                             | term term → id num

  • Where the terminals if, then, else, relop, id and num generates the set of strings given by the following regular definitions,

           if → if

           then → then

           relop → < | <= | = | <> | > | >=

           letter → A | B | . . . | Z | a | b | . . . | z

           digit → 0 | 1 | 2 | . . . | 9

           id → letter (letter | digit)*

           num → digit+ ()?(E(+/-)?digit+ )?

  • For this language the lexical analyzer will recognize the keyword if, then, else, as well as the lexeme denoted by relop, id and num.
  • num represents the unsigned integer and real numbers of pascal
  • Lexical analyzer will isolate the next token in the input buffer and produces token and attribute value as an output

Leave a Reply