Q. In an LR parser, what is the purpose of the 'shift' action?
A.
To reduce a production.
B.
To push a state onto the stack.
C.
To pop a state from the stack.
D.
To accept the input.
Show solution
Solution
The 'shift' action in an LR parser moves the next input symbol onto the stack and transitions to a new state.
Correct Answer:
B
— To push a state onto the stack.
Learn More →
Q. In LR parsing, what is the significance of the 'shift' action?
A.
To reduce the current production.
B.
To move the input pointer to the next token.
C.
To add a new production to the parse tree.
D.
To backtrack to a previous state.
Show solution
Solution
The 'shift' action in LR parsing moves the input pointer to the next token.
Correct Answer:
B
— To move the input pointer to the next token.
Learn More →
Q. In the context of LL parsing, what does the '1' in LL(1) signify?
A.
One lookahead token is used.
B.
One leftmost derivation is produced.
C.
One parsing table is required.
D.
One recursive call is made.
Show solution
Solution
The '1' in LL(1) indicates that one lookahead token is used to make parsing decisions.
Correct Answer:
A
— One lookahead token is used.
Learn More →
Q. What does LR stand for in LR parsing?
A.
Left-to-right
B.
Right-to-left
C.
Left-to-right with lookahead
D.
Right-to-left with lookahead
Show solution
Solution
LR parsing stands for Left-to-right parsing with a rightmost derivation in reverse.
Correct Answer:
A
— Left-to-right
Learn More →
Q. What does the 'reduce' action do in an LR parser?
A.
It shifts the next input symbol onto the stack.
B.
It pops symbols from the stack and replaces them with a non-terminal.
C.
It accepts the input string.
D.
It generates an error.
Show solution
Solution
The 'reduce' action in an LR parser pops a number of symbols from the stack and replaces them with a non-terminal according to a production rule.
Correct Answer:
B
— It pops symbols from the stack and replaces them with a non-terminal.
Learn More →
Q. What is a common limitation of LL parsers?
A.
They cannot handle ambiguous grammars.
B.
They require more memory than LR parsers.
C.
They can only parse regular languages.
D.
They are slower than LR parsers.
Show solution
Solution
LL parsers cannot handle ambiguous grammars, which limits their applicability.
Correct Answer:
A
— They cannot handle ambiguous grammars.
Learn More →
Q. What is the main characteristic of LL parsing?
A.
It uses a top-down approach.
B.
It uses a bottom-up approach.
C.
It requires left recursion.
D.
It is non-deterministic.
Show solution
Solution
LL parsing is a top-down parsing technique that processes the input from left to right and constructs a leftmost derivation of the sentence.
Correct Answer:
A
— It uses a top-down approach.
Learn More →
Q. What is the primary advantage of using LR parsing over LL parsing?
A.
Simplicity of implementation.
B.
Ability to handle left recursion.
C.
Lower memory usage.
D.
Faster parsing speed.
Show solution
Solution
LR parsing can handle left recursion, which is a limitation of LL parsing.
Correct Answer:
B
— Ability to handle left recursion.
Learn More →
Q. What is the primary purpose of a parsing table in LR parsing?
A.
To store the grammar rules.
B.
To determine the next action based on the current state and input symbol.
C.
To keep track of the parse tree.
D.
To optimize the parsing process.
Show solution
Solution
The parsing table in LR parsing is used to determine the next action based on the current state and input symbol.
Correct Answer:
B
— To determine the next action based on the current state and input symbol.
Learn More →
Q. What is the role of the parsing table in an LR parser?
A.
To store the grammar rules.
B.
To determine the next action based on the current state and input symbol.
C.
To keep track of the parse tree.
D.
To manage memory allocation.
Show solution
Solution
The parsing table in an LR parser is used to determine the next action (shift, reduce, accept, or error) based on the current state and the next input symbol.
Correct Answer:
B
— To determine the next action based on the current state and input symbol.
Learn More →
Q. Which of the following grammars can be parsed using LL(1) parsing?
A.
Left-recursive grammars
B.
Ambiguous grammars
C.
Non-left-recursive and unambiguous grammars
D.
Context-free grammars only
Show solution
Solution
LL(1) parsing can only be applied to non-left-recursive and unambiguous grammars.
Correct Answer:
C
— Non-left-recursive and unambiguous grammars
Learn More →
Q. Which of the following is a key advantage of LR parsing over LL parsing?
A.
LR parsing can handle left recursion.
B.
LR parsing is simpler to implement.
C.
LL parsing can handle more complex grammars.
D.
LR parsing requires less memory.
Show solution
Solution
LR parsing can handle left recursion, which LL parsing cannot.
Correct Answer:
A
— LR parsing can handle left recursion.
Learn More →
Q. Which of the following is a requirement for an LL(1) parser?
A.
The grammar must be left recursive.
B.
The grammar must be ambiguous.
C.
The grammar must be free of left recursion.
D.
The grammar must have multiple left factors.
Show solution
Solution
An LL(1) parser requires the grammar to be free of left recursion to ensure that it can make decisions based on a single lookahead token.
Correct Answer:
C
— The grammar must be free of left recursion.
Learn More →
Q. Which of the following is NOT a type of LR parser?
A.
SLR
B.
LALR
C.
LR(1)
D.
LL(1)
Show solution
Solution
LL(1) is not a type of LR parser; it is a type of LL parser.
Correct Answer:
D
— LL(1)
Learn More →
Q. Which of the following is true about SLR parsing?
A.
It uses a single lookahead token.
B.
It is a type of LL parsing.
C.
It can handle all context-free grammars.
D.
It is less powerful than canonical LR parsing.
Show solution
Solution
SLR parsing is less powerful than canonical LR parsing as it uses a simpler method for constructing the parsing table.
Correct Answer:
D
— It is less powerful than canonical LR parsing.
Learn More →
Q. Which of the following parsing techniques can handle a larger class of grammars?
A.
LL parsing
B.
LR parsing
C.
Recursive descent parsing
D.
Predictive parsing
Show solution
Solution
LR parsing can handle a larger class of grammars compared to LL parsing, including all deterministic context-free grammars.
Correct Answer:
B
— LR parsing
Learn More →
Q. Which of the following statements is true about LL and LR parsers?
A.
LL parsers are more powerful than LR parsers.
B.
LR parsers can handle all LL grammars.
C.
LL parsers can handle all LR grammars.
D.
Both LL and LR parsers are equivalent in power.
Show solution
Solution
LR parsers can handle all LL grammars, but not all LR grammars can be parsed by LL parsers.
Correct Answer:
B
— LR parsers can handle all LL grammars.
Learn More →
Q. Which parsing technique is generally more powerful, LL or LR?
A.
LL
B.
LR
C.
Both are equally powerful.
D.
Neither is powerful.
Show solution
Solution
LR parsing is generally more powerful than LL parsing as it can handle a larger class of grammars.
Correct Answer:
B
— LR
Learn More →
Showing 1 to 18 of 18 (1 Pages)