Compiler Design
Practice questions on compiler design concepts including lexical analysis, parsing techniques, grammars, finite automata, and code generation.
Questions
Which of the following is a similarity between macro processor and compiler pre-processor?
- Functionally, both are same.
- Both are used to preprocesse the assembler directives.
- Both are used to preprocess the compiler directives.
- Both provide subroutine facility to language processor.
- Both are different, they do not have any similarity.
Both compiler and assembler are similar in atleast one function. Which of the following options correctly indicates the similarity?
- Both converts high level language file in to object file.
- Both uses pre-processors before processing main program of the source program.
- Both converts the source program into machine language program.
- Both uses symbol table in second pass to convert the source into machine language.
- Both option 3 and option 4 are correct.
Cross compiler generates code for which of the following targets?
- The target machine on which it is being executed.
- The target machine other than the machine on which it is being executed.
- By default, the target is server machine of the node on which it is being executed.
- Cross compiler does not generate machine code.
- Both 2 and 3
Which of the following options explains the attributes of a token in compiler design?
- Concrete manifestation of a token in the text
- Key words
- White spaces
- Value of an integer token defines value of identifier M
- Delimiter
Display char is an identifier for a compiler of a given language and it recognize it as token. The NFA will find it as which of the following?
- Token
- Token recognizer
- Expression recognizer
- State
- None of the above
Which of the following analysers of compiler uses parse tree of a source program?
- Lexical
- Syntax
- Code generator
- Boot strap loader
- Intermediate code generator
During compilation of the C statement
for(i=1;i<10;i++)
The compiler converts it as detailed below:
for-------keyword,
i----identifier ,
1 & 10 ---------constants or literals,
( =,<,++)------operator.
Above conversion is a valid conversion. The compiler does it during which of the following analysis phases?
- Semantic analysis
- Syntax analysis
- Optimization analysis
- Lexical analysis
- Code generation
Which of the following is a necessary condition for a single pass compiler?
- It generates symbol table and generates code afterwards.
- It allows labels, which can be defined after it is used.
- It does not allow defining a function after it has been called in the program.
- It allows a forward definition of a symbol or identifier.
- None of the above
In a perfectly designed compiler and perfectly coded program, a system error, i.e. memory insufficiency occurs while executing a recursive function call and execution of the program is terminated. What is the reason behind the occurence of this error?
- Compiler
- Program, since queue entries are overflowed
- Stack overflow
- Number of stacks assigned to this program crossed the maximum limit assigned to compiler
- Symbol table over flow
Which of the following correctly defines the difference between finite automation and non-determistic finite automation?
- Q is finite and non-empty set of states in FA and empty set of states in NFA.
- δ is from Q X ∑ to 2φ in NFA and Q X ∑ to Q in FA.
- ∑ is a finite non empty set of inputs in FA but it is empty set of input in NFA.
- q0 is initial state in FA and final state in NFA.
- None of the above
A grammar, which does not have any left or right rule can be recognized as which of the following?
- Context sensitive grammar
- Context content grammar
- Context free grammar
- Context derived grammar
- None of the above
Operator precedence, SLR, CLR, LALR, Shift reduce
The above given parsers are
- top down parsers
- bottom up parsers
- centre break parsers
- recursive distance parsers
- not parsers, but grammars
Back tracking is required in which of the following parsing techniques?
- Bottom up
- Operator precedence
- Top down
- Top up
- Shift reduce
Given a statement : w = abbcde
In which of the following parsers is the right most derivative in reverse technique applied?
- Bottom up
- Top down
- Centre break
- Recursive descent parser
- None of the above
Which of the following types of intermediate codes is used in a single pass compiler?
- Postfix notations
- Syntax tree
- Quadrupples
- Intermediate code is not generated at all
- Tripples