Compiler interview questions

21. What is code generator ?
Code Generator produces the object code by deciding on the memory locations for data, selecting code to access each datum and selecting the registers in which each computation is to be done. Many computers have only a few high speed registers in which computations can be performed quickly. A good code generator would attempt to utilize registers as efficiently as possible.

22. What is Transition Diagram ?
Transition Diagram has a collection of nodes or circles, called states. Each state represents a condition that could occur during the process of scanning the input looking for a lexeme that matches one of several patterns .

23. What are the operations on languages.
Union – L U M ={s | s is in L or s is in M}
Concatenation – LM ={st | s is in L and t is in M}
Kleene Closure – L* (zero or more concatenations of L)
Positive Closure – L+ ( one or more concatenations of L)

24. What is code generation in compiler ?
The last phase of translation is code generation. A number of optimizations to reduce the length of machine language program are carried out during this phase. The output of the code generator is the machine language program of the specified computer.

25. What are Token, Lexeme, Pattern ?
Token: Token is a sequence of characters that can be treated as a single logical entity.
Typical tokens are,1) Identifiers 2) keywords 3) operators 4) special symbols 5)constants
Pattern: A set of strings in the input for which the same token is produced as output. This set of strings is described by a rule called a pattern associated with the token.
Lexeme: A lexeme is a sequence of characters in the source program that is matched by the pattern for a token.

Author: user

Leave a Reply