MCQ Bank
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
How is the attribute evaluation order determined in the oblivious methodology?
- A) Chosen at compiler design time
- B) Based on the syntax tree structure
- C) By considering the attribute dependencies
- D) By analyzing the attribute rules
Which two linear intermediate representations (IRs) are commonly used in modern compilers?
- A) High-level language and low-level language
- B) Stack-machine code and three-address code
- C) Register-transfer language and SSA form
- D) Assembly code and bytecode
What is the characteristic of the ordering of attribute evaluation in the rule-based methodology?
- A) It is fixed and determined at compiler-generation time.
- B) It is determined based on the values of the attributes.
- C) It is dynamically determined during the compilation process.
- D) It is randomly assigned during the dependency graph construction.
In the modified parser for the implementation of ad-hoc scheme for semantic analysis, what happens when a reduction by the production rule A → β occurs?
- A) The parser pops 2×|β| items from the stack.
- B) The parser pops 3×|β| items from the stack.
- C) The parser pushes 2×|β| items onto the stack.
- D) The parser pushes 3×|β| items onto the stack.