Compiler Design

Practice questions on compiler design concepts including lexical analysis, parsing techniques, grammars, finite automata, and code generation.

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following is a similarity between macro processor and compiler pre-processor?

  1. Functionally, both are same.
  2. Both are used to preprocesse the assembler directives.
  3. Both are used to preprocess the compiler directives.
  4. Both provide subroutine facility to language processor.
  5. Both are different, they do not have any similarity.
Question 2 Multiple Choice (Single Answer)

Both compiler and assembler are similar in atleast one function. Which of the following options correctly indicates the similarity?

  1. Both converts high level language file in to object file.
  2. Both uses pre-processors before processing main program of the source program.
  3. Both converts the source program into machine language program.
  4. Both uses symbol table in second pass to convert the source into machine language.
  5. Both option 3 and option 4 are correct.
Question 3 Multiple Choice (Single Answer)

Cross compiler generates code for which of the following targets?

  1. The target machine on which it is being executed.
  2. The target machine other than the machine on which it is being executed.
  3. By default, the target is server machine of the node on which it is being executed.
  4. Cross compiler does not generate machine code.
  5. Both 2 and 3
Question 4 Multiple Choice (Single Answer)

Which of the following options explains the attributes of a token in compiler design?

  1. Concrete manifestation of a token in the text
  2. Key words
  3. White spaces
  4. Value of an integer token defines value of identifier M
  5. Delimiter
Question 5 Multiple Choice (Single Answer)

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?

  1. Token
  2. Token recognizer
  3. Expression recognizer
  4. State
  5. None of the above
Question 6 Multiple Choice (Single Answer)

Which of the following analysers of compiler uses parse tree of a source program?

  1. Lexical
  2. Syntax
  3. Code generator
  4. Boot strap loader
  5. Intermediate code generator
Question 7 Multiple Choice (Single Answer)

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?

  1. Semantic analysis
  2. Syntax analysis
  3. Optimization analysis
  4. Lexical analysis
  5. Code generation
Question 8 Multiple Choice (Single Answer)

Which of the following is a necessary condition for a single pass compiler?

  1. It generates symbol table and generates code afterwards.
  2. It allows labels, which can be defined after it is used.
  3. It does not allow defining a function after it has been called in the program.
  4. It allows a forward definition of a symbol or identifier.
  5. None of the above
Question 9 Multiple Choice (Single Answer)

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?

  1. Compiler
  2. Program, since queue entries are overflowed
  3. Stack overflow
  4. Number of stacks assigned to this program crossed the maximum limit assigned to compiler
  5. Symbol table over flow
Question 10 Multiple Choice (Single Answer)

Which of the following correctly defines the difference between finite automation and non-determistic finite automation?

  1. Q is finite and non-empty set of states in FA and empty set of states in NFA.
  2. δ is from Q X ∑ to 2φ in NFA and Q X ∑ to Q in FA.
  3. ∑ is a finite non empty set of inputs in FA but it is empty set of input in NFA.
  4. q0 is initial state in FA and final state in NFA.
  5. None of the above
Question 11 Multiple Choice (Single Answer)

A grammar, which does not have any left or right rule can be recognized as which of the following?

  1. Context sensitive grammar
  2. Context content grammar
  3. Context free grammar
  4. Context derived grammar
  5. None of the above
Question 12 Multiple Choice (Single Answer)

Operator precedence, SLR, CLR, LALR, Shift reduce

The above given parsers are

  1. top down parsers
  2. bottom up parsers
  3. centre break parsers
  4. recursive distance parsers
  5. not parsers, but grammars
Question 13 Multiple Choice (Single Answer)

Back tracking is required in which of the following parsing techniques?

  1. Bottom up
  2. Operator precedence
  3. Top down
  4. Top up
  5. Shift reduce
Question 14 Multiple Choice (Single Answer)

Given a statement : w = abbcde
In which of the following parsers is the right most derivative in reverse technique applied?

  1. Bottom up
  2. Top down
  3. Centre break
  4. Recursive descent parser
  5. None of the above
Question 15 Multiple Choice (Single Answer)

Which of the following types of intermediate codes is used in a single pass compiler?

  1. Postfix notations
  2. Syntax tree
  3. Quadrupples
  4. Intermediate code is not generated at all
  5. Tripples