Transition diagram for relops
|
token is relop , lexeme is >=
|
token is relop, lexeme is >
|
|
token is relop, lexeme is <
|
token is relop, lexeme is <>
|
token is relop, lexeme is <= |
token is relop, lexeme is =
|
token is relop , lexeme is >=
|
token is relop, lexeme is >
|
In case of < or >, we need a lookahead to see if it is a <, = , or <> or = or >. We also need a global data structure which stores all the characters. In lex, yylex is used for storing the lexeme. We can recognize the lexeme by using the transition diagram shown in the slide. Depending upon the number of checks a relational operator uses, we land up in a different kind of state like >= and > are different. From the transition diagram in the slide it's clear that we can land up into six kinds of relops.
|