MCQ Bank
The canonical collection is used to generate which of the following parsing tables?
- A) Action and goto tables
- B) Production and symbol tables
- C) First and follow tables
- D) Closure and reduction tables
LR parsers are commonly used for:
- A) Syntax analysis
- B) Lexical analysis
- C) Code generation
- D) Register Allocation
Which direction does a bottom-up parser use to build the parse tree?
- A) From the root to the leaves.
- B) From the right to the left.
- C) From the left to the right.
- D) From the leaves to the root.
The augmented grammar is particularly important in which parsing algorithm?
- A) Top-down parsing.
- B) Recursive descent parsing.
- C) LL(1) parsing.
- D) LR(1) parsing.
What should be added to the LL(1) parsing table entry M[A, a] during the construction process?
- A) The FIRST set of A.
- B) The FOLLOW set of A.
- C) The production rule A → α.
- D) The non-terminal A.
In the LR item [S' → •S, $], the "S" represents a non-terminal symbol in the grammar.
- A) True
- B) False
- C)
- D)
What is the main characteristic of linear IRs?
- A) They represent the program as a linear sequence of instructions or statements.
- B) They represent the program as a graph.
- C) They combine elements of graphical and linear representations.
- D) They allow for complex program structures and sophisticated analyses.
The size of an LR(1) parsing table can be calculated by multiplying the number of ___________ with the number of symbols.
- A) Rules
- B) Terminals
- C) Actions
- D) States
In attribute grammars, an attribute (e.g., val) of a symbol (e.g., B) can be written as ____________.
- A) val.B
- B) val@B
- C) B@val
- D) B.val
In YACC, what does the notation $2 refer to?
- A) The first symbol on the left-hand side of a production
- B) The second symbol on the right-hand side of a production
- C) The first symbol on the right-hand side of a production
- D) The second symbol on the left-hand side of a production
Why have LALR(1) grammars become a standard for parser generators?
- A) They offer better performance than other grammars.
- B) They are compatible with natural languages.
- C) They have widespread adoption and support for programming languages.
- D) They allow for automatic code generation.
What is the purpose of the $3 notation in YACC?
- A) To refer to the third symbol on the right-hand side of a production
- B) To refer to the first symbol on the right-hand side of a production
- C) To refer to the second symbol on the right-hand side of a production
- D) To refer to the fourth symbol on the right-hand side of a production
Compared to LR(1), LALR(1) parsing tables typically have:
- A) No states
- B) Less states
- C) Same states
- D) More states
Which section in a YACC specification file contains the "grammar rules"?
- A) First Section
- B) Fourth Section
- C) Third Section
- D) Second Section
Why is a topological sort necessary in the dynamic method of attribute grammar evaluation?
- A) It simplifies the construction of the parse tree.
- B) It ensures that attribute dependencies are resolved correctly.
- C) It guarantees efficient attribute computation.
- D) It eliminates circular dependencies.
What does the notation $$ refer to in YACC?
- A) The symbol on the right-hand side of the production
- B) The symbol on the down-hand side of the production
- C) The symbol on the left-hand side of the production
- D) The symbol on the up-hand side of the production
What is the purpose of using an intermediate representation (IR) in a compiler?
- A) To eliminate the need for multiple passes in the compilation process.
- B) To directly translate high-level code into machine code.
- C) To provide a structured and uniform representation for code analysis and transformation.
- D) To simplify the debugging process for the compiled code.
In attribute grammars, when the parse tree is peeled away, we get the attribute independence graph
- A) True
- B) False
- C)
- D)
What is the advantage of adopting YACC notation in the ad-hoc scheme for semantic analysis?
- A) It provides a standardized approach for attribute handling.
- B) It simplifies the attribute dependency analysis process.
- C) It guarantees efficient attribute propagation.
- D) It ensures compatibility with existing parsing tools.
Which category of intermediate representation (IR) represents the program as a graph?
- A) Linear IRs
- B) Hybrid IRs
- C) Sequential IRs
- D) Graphical IRs