Order PDF of any content from our website with a little minor Fee to donate for hard work. Online MCQs are fully free but PDF books are paid. For details: contact whatsapp +923028700085 Important notes based PDF Books are available in very little price, starting from 500/-PKR; Order Now: contact whatsapp +923028700085

VU Past Papers – CS606 Compiler Design MCQs and Subjective Solved

CS606 – Compiler Design (All Midterm Papers, Quizzes & MCQs + Subjective Solved)


MCQs / Quizzes

Q1: LR parsers can handle ___ grammars.
(A) Left-recursive
(B) File-recursive
(C) End-recursive
(D) Start-recursive
Answer: (A) Left-recursive (Page no: 163)

Q2: Convert the reloadable machine code into absolute machine code by linking library and reloadable object files.
(A) Assembler
(B) Loader/link-editor
(C) Compiler
(D) Preprocessor
Answer: (B) Loader/link-editor

Q3: Follow of B in the grammar:

A --> B C D
B --> h B | ε
C --> C g | g | C h | i
D --> A B | ε

(A) . h
(B) g, h, i, $
(C) g, i g
(D) None of given
Answer: (B) g, h, i, $

Q4: Follow of C in the same grammar.
(A) g, h, i, $
(B) g, h, $
(C) h, i, $
(D) h, g, $
Answer: (A) g, h, i, $ (Page no: 47)

Q5: An important component of semantic analysis is ___
(A) Code checking
(B) Type checking
(C) Flush checking
(D) None of the given
Answer: (B) Type checking (Page no: 6)

Q6: In PASCAL, ___ represents the inequality test.
(A) :=
(B) =
(C) <>
(D) None of the given
Answer: (C) <>

Q7: Lexical Analyzer generator ___ is written in Java.
(A) Flex
(B) JLex
(C) Complex
(D) None of given
Answer: (B) JLex (Page no: 26)

Q8: ___ avoids hardware stalls and interlocks.
(A) Register allocation
(B) Instruction scheduling
(C) Instruction selection
(D) None of given
Answer: (B) Instruction scheduling (Page no: 10)

Q9: First of A in the grammar:

A --> B C D
B --> h B | ε
C --> C g | g | C h | i
D --> A B | ε

(A) h, g, i
(B) g, h
(C) None of the given
(D) All of the above
Answer: (A) h, g, i

Q10: Recursive parsing is done for ___ grammar.
(A) Decent
(B) Ascent
(C) Forward
(D) Backward
Answer: (A) Decent (Page no: 47)

Q11: One of the core tasks of a compiler is to generate fast and compact executable code.
(A) True
(B) False
Answer: (A) True

Q12: Left factoring of a grammar is done to save the parser from backtracking.
(A) True
(B) False
Answer: (A) True (Page no: 61)

Q13: Responsibility of ___ is to produce fast and compact code.
(A) Instruction selection
(B) Register allocation
(C) Instruction scheduling
(D) None of given
Answer: (A) Instruction selection (Page no: 9)

Q14: Algorithm used in DFA minimization.
(A) James’s
(B) Robert’s
(C) Hopcroft’s
(D) None of given
Answer: (C) Hopcroft’s (Page no: 25)

Q15: Compilers are sometimes classified as:
(A) Single pass
(B) Multi pass
(C) Load and go
(D) All of the given
Answer: (D) All of the given

Q16: In multi-pass compiler, during the first pass it gathers information about ___
(A) Declaration
(B) Bindings
(C) Static information
(D) None of the given
Answer: (A) Declaration

Q17: Flex is an automated tool used to get the minimized DFA (scanner).
(A) True
(B) False
Answer: (A) True

Q18: In compilation process, Hierarchical analysis is also called ___
(A) Parsing
(B) Syntax analysis
(C) Both Parsing and Syntax analysis
(D) None of given
Answer: (C) Both Parsing and Syntax analysis

Q19: For each language to make LL(1) grammar, we take two steps: remove left recursion and ___
(A) Apply fin sequence
(B) Apply left factoring
(C) Both
(D) None of the given
Answer: (C) Remove left recursion and Apply left factoring

Q20: Parser takes tokens from scanner and tries to generate ___
(A) Binary Search tree
(B) Parse tree
(C) Syntax trace
(D) None of the given
Answer: (B) Parse tree (Page no: 6)

Q21: Front-end of a two-pass compiler takes ___ as input.
(A) Source code
(B) Intermediate Representation (IR)
(C) Machine Code
(D) None of the given
Answer: (A) Source code (Page no: 5)

Q22: In DFA minimization, we construct one ___ for each group of states from initial DFA.
(A) State
(B) NFA
(C) PDA
(D) None of given
Answer: (A) State (Page no: 25)

Q23: NFA is easier to implement as compared to DFA.
(A) True
(B) False
Answer: (A) True (Page no: 19)

Q24: Can a DFA simulate NFA?
(A) Yes
(B) No
(C) Sometimes
(D) Depends upon NFA
Answer: (A) Yes

Q25: Which statement is true about Regular Languages?
(A) Most popular for specifying tokens
(B) Based on simple and useful theory
(C) Easy to understand
(D) All of the given
Answer: (D) All of the given


Short Answer / Subjective Questions

Q1: What is the role of Automatic Code Generator with respect to compiler?
Answer: It generates efficient tokens automatically. It is known as a Lexer generator.

Q2: How does a Linker play an important role in compiler construction?
Answer: A linker or link editor takes one or more object files generated by a compiler and combines them into a single executable program.

Q3: Calculate FOLLOW set for grammar:

E → id Q
Q → ER | ε
R → +Q | -Q | *Q | /Q

Answer:

  • Terminals: id, +, -, *, /, ε
  • Non-terminals: E, Q, R
  • Follow{E} = {+, -, *, /, $}
  • Follow{Q} = {+, -, *, /}
  • Follow{R} = {+, -, *, /}

Q4: Calculate FIRST set for grammar:

S → AB  
A → a | ε 
B → b | ε

Answer:

  • FIRST{A} = {a, ε}
  • FIRST{B} = {b, ε}
  • FIRST{S} = {a, b, ε}

Q5: Calculate FIRST set for grammar:

A → B C D  
B → h B | ε 
C → C g | g | C h | i 
D → A B | ε

Answer:

  • FIRST{B} = {h, ε}
  • FIRST{C} = {g, i}
  • FIRST{D} = {h, g, i, ε}
  • FIRST{A} = {h, g, i}

Q6: What is Register Allocation?
Answer: Registers in CPU provide high-speed access to operands. Optimal register allocation ensures each operand is in a register when used. The problem is NP-Complete.

Q7: What is “up frontier discovery” useful for?
Answer: In bottom-up parsing, the upper edge of the partially constructed parse tree is the upper frontier, used to control parsing in top-down parsers.

Q8: Write a regular expression for language of all words starting and ending with different letters.
Answer: a(a+b)*b + b(a+b)*a

Q9: Explain ambiguous grammar with string “ab”:

S → ABAB  
A → aA | ε 
B → bB | ε

Answer: String “ab” can have multiple parse trees due to ε-productions, showing ambiguity.

Q10: How to implement recursive descent parser using OOP?
Answer: Each non-terminal is represented by a class. Object instances store pointers to parse tree nodes. C++ or Java can be used.

Contents Copyrights Reserved By T4Tutorials