Explain the different methods of handling reserved words that look like identifiers.


There are two ways, you can handle reserved words that look like identifiers:

► Put the reserved words in a symbol table initially, with a field indicating that they’re not ordinary identifiers, and tells what tokens do they represent.

When we find an identifier, a call to installID() places it in the symbol table if it’s not already there, and returns a pointer to the symbol table entry for the lexeme found. Any identifier not in the table is recognized as an 'id’.

► Create separate transition diagrams for each keyword, consisting of states representing the situation the keyword is to be detected.

The diagram consists of states representing each letter in the keyword, and check if the identifier has ended, with proper suffix detection. For e.g. 'then' should not be matched in 'thenextstep'.



Share to whatsapp

More Questions from System Software and Compiler Design Module 3

Write a short note on the structure of Generated Analyzer
View
Explain the various phases of the compiler with a simple example
View
Write a short note on Compilers and Interpreters. Also explain the various units of language processing system.
View
Discuss the various applications of compiler technology
View
Explain how transition diagram is used to identify relational operator during Lexical Analysis. Write the code for same
View
Explain the different methods of handling reserved words that look like identifiers.
View
Explain Input Buffering. What is the drawback of using one buffer scheme and explain how it is overcome?
View