Compiler Design | Transition diagram for Identifiers

Transition diagram is a special kind of flowchart for language analysis. In transition diagram the boxes of flowchart are drawn as circle and called as states. States are connected by arrows called as edges. The label or weight on edge indicates the input character that can appear after that state.

Transition diagram of identifier is given below:

This transition diagram for identifier reading first letter and after that letter or digit until the next input character is delimiter for identifier, means the character that is neither letter nor digit. To turn up the transition diagram into a program we construct the program segment code for each state of transition diagram.

Program segment code for each state is given below:


if LETTER(C) then goto State 1
else FAIL() 


if LETTER(C) OR DIGIT(C) then goto State 1
else if DELIMITER(C) then goto State 2
else FAIL() 



Next character for input buffer we use GETCHAR() which return next character.
LETTER(C) is a procedure which returns the true value if and only if C is a letter.
FAIL(C) is a routine which RETRACT the look ahead pointer and start up the next transition diagram otherwise call error routine.
DIGIT(C) is a procedure which returns the true value if and only if C is a digit.
DELIMITER(C) is a procedure which returns the true value if and only if C Is a character that could follow the identifier for example blank symbol, arithmetic, logical operator, left parenthesis, right parenthesis, +, :, ; etc.
Because DELIMITER is not part of identifier therefore we must RETRACT the look ahead pointer one character for this purpose we use the RETRACT() procedure .
Because identifier has a value so to install the value of identifier in symbol table we use INSTALL() procedure.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.