Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Syntax Analysis &Syntax Directed Translation MCQs

1. Which parsing technique is known for starting from the root of the parse tree and recursively expands nodes to match the input?

a) Top-down parsing
b) Bottom-up parsing
c) Recursive descent parsing
d) Brute force parsing

Answer: a) Top-down parsing
Explanation: Top-down parsing begins with the start symbol of the grammar and attempts to match the input string by recursively expanding non-terminals using production rules.

2. Which parsing approach explores all possible parse trees in search of the correct one?

a) Top-down parsing
b) Bottom-up parsing
c) Brute force parsing
d) Recursive descent parsing

Answer: c) Brute force parsing
Explanation: Brute force parsing involves exploring all possible parse trees to find the correct one, which can be highly inefficient for large grammars or inputs.

3. Which parsing technique often uses a stack data structure to keep track of partially matched symbols?

a) Top-down parsing
b) Bottom-up parsing
c) Recursive descent parsing
d) Predictive parsing

Answer: b) Bottom-up parsing
Explanation: Bottom-up parsing starts with the input string and tries to build the parse tree from leaves to the root, using a stack to keep track of partially matched symbols.

4. Which parsing method utilizes a set of production rules to determine the next step based on the current input symbol?

a) Bottom-up parsing
b) Recursive descent parsing
c) Predictive parsing
d) LR parsing

Answer: c) Predictive parsing
Explanation: Predictive parsing uses a set of production rules and a look-ahead symbol to predict which production to apply based on the current input symbol.

5. Which parsing technique is susceptible to left recursion and left factoring problems?

a) Recursive descent parsing
b) Predictive parsing
c) Bottom-up parsing
d) Operator precedence parsing

Answer: b) Predictive parsing
Explanation: Predictive parsing can struggle with left recursion and left factoring, which may require grammar transformations to resolve.

6. LR parsers belong to which category of parsing techniques?

a) Top-down parsing
b) Bottom-up parsing
c) Recursive descent parsing
d) Predictive parsing

Answer: b) Bottom-up parsing
Explanation: LR parsers are a type of bottom-up parsing technique, which build the parse tree from the leaves to the root.

7. Which LR parsing variant is more powerful and efficient compared to SLR parsing, but requires more memory?

a) SLR parsing
b) LALR parsing
c) LR(1) parsing
d) LR(0) parsing

Answer: b) LALR parsing
Explanation: LALR (Look-Ahead LR) parsing is more powerful and efficient compared to SLR (Simple LR) parsing, but it requires more memory.

8. Which parsing technique assigns priorities to operators to resolve ambiguities in expressions?

a) Top-down parsing
b) Bottom-up parsing
c) Operator precedence parsing
d) Recursive descent parsing

Answer: c) Operator precedence parsing
Explanation: Operator precedence parsing resolves ambiguities in expressions by assigning priorities to operators, determining which operations to perform first.

9. Which parsing method typically involves constructing a parse tree that represents the syntactic structure of a program?

a) Bottom-up parsing
b) Top-down parsing
c) Recursive descent parsing
d) Syntax-directed parsing

Answer: d) Syntax-directed parsing
Explanation: Syntax-directed parsing involves constructing a parse tree that represents the syntactic structure of a program, often along with semantic actions.

10. Which parsing technique can efficiently handle left-recursive grammars?

a) Predictive parsing
b) Recursive descent parsing
c) LR parsing
d) Operator precedence parsing

Answer: c) LR parsing
Explanation: LR parsing can efficiently handle left-recursive grammars by using a bottom-up approach combined with a lookahead mechanism.

11. Which parsing method starts from the input symbols and works towards the start symbol of the grammar?

a) Bottom-up parsing
b) Top-down parsing
c) Recursive descent parsing
d) LR parsing

Answer: a) Bottom-up parsing
Explanation: Bottom-up parsing starts from the input symbols and works towards the start symbol of the grammar, building the parse tree in the process.

12. Which parsing technique requires the grammar to be unambiguous and have no left recursion?

a) Predictive parsing
b) Recursive descent parsing
c) Operator precedence parsing
d) Bottom-up parsing

Answer: a) Predictive parsing
Explanation: Predictive parsing requires the grammar to be unambiguous and have no left recursion to construct a predictive parsing table.

13. Which parsing technique can be implemented using a recursive approach to match input tokens with grammar rules?

a) Predictive parsing
b) Bottom-up parsing
c) Recursive descent parsing
d) Operator precedence parsing

Answer: c) Recursive descent parsing
Explanation: Recursive descent parsing involves implementing a parser by recursively matching input tokens with grammar rules, typically in a top-down manner.

14. Which parsing method is suitable for constructing an abstract syntax tree (AST) representation of a program?

a) Predictive parsing
b) Bottom-up parsing
c) Syntax-directed parsing
d) LR parsing

Answer: c) Syntax-directed parsing
Explanation: Syntax-directed parsing is suitable for constructing an abstract syntax tree (AST) representation of a program, as it associates semantic actions with grammar productions.

15. Which parsing technique can efficiently handle ambiguous grammars?

a) Predictive parsing
b) Operator precedence parsing
c) LR parsing
d) Recursive descent parsing

Answer: c) LR parsing
Explanation: LR parsing can efficiently handle ambiguous grammars due to its bottom-up approach and the use of a lookahead mechanism.

16. Which parsing method typically involves constructing a parse tree in a recursive manner starting from the root?

a) Predictive parsing
b) Bottom-up parsing
c) Recursive descent parsing
d) Operator precedence parsing

Answer: c) Recursive descent parsing
Explanation: Recursive descent parsing involves constructing a parse tree in a recursive manner starting from the root, often using a top-down approach.

17. Which parsing technique employs a parsing table to determine the next action based on the current input symbol and the top of the stack?

a) Recursive descent parsing
b) Predictive parsing
c) LR parsing
d) Operator precedence parsing

Answer: c) LR parsing
Explanation: LR parsing employs a parsing table to determine the next action based on the current input symbol and the top of the stack, making it efficient for parsing large grammars.

18. Which parsing approach typically requires the grammar to be transformed to eliminate left recursion and ambiguity?

a) Bottom-up parsing
b) Predictive parsing
c) Recursive descent parsing
d) Operator precedence parsing

Answer: b) Predictive parsing
Explanation: Predictive parsing typically requires the grammar to be transformed to eliminate left recursion and ambiguity before constructing the predictive parsing table.

19. Which parsing technique is used for parsing arithmetic expressions and other similar constructs?

a) Predictive parsing
b) Bottom-up parsing
c) Operator precedence parsing
d) Recursive descent parsing

Answer: c) Operator precedence parsing

Explanation: Operator precedence parsing is specifically designed for parsing expressions and other constructs where operator precedence matters.

20. Which parsing method is known for its ease of implementation but may suffer from backtracking in case of incorrect predictions?

a) Bottom-up parsing
b) Recursive descent parsing
c) Predictive parsing
d) Operator precedence parsing

Answer: c) Predictive parsing
Explanation: Predictive parsing is relatively easy to implement but may suffer from backtracking if incorrect predictions are made during parsing, potentially affecting its efficiency.

Leave a Comment