In shift-reduce parsing, what does the 'shift' action specifically do?
Think about what happens when the parser reads the next symbol but has not yet reduced.
The 'shift' action takes the next symbol from the input and pushes it onto the stack, preparing for possible reductions later.
What does the 'reduce' action do in shift-reduce parsing?
Consider how the parser recognizes a pattern matching the right side of a grammar rule.
Reduce replaces the matched symbols on the stack with the corresponding non-terminal from the grammar, effectively recognizing a phrase.
Given the input string id + id * id and a grammar where id is a terminal, which sequence of actions correctly parses this input using shift-reduce parsing?
Remember operator precedence: multiplication (*) has higher precedence than addition (+).
The correct sequence respects operator precedence by reducing the multiplication before addition, matching the grammar rules properly.
What kind of error does a shift-reduce parser detect when it encounters a situation where it can either shift or reduce but neither action leads to a valid parse?
Consider what happens when no valid parsing action can continue the process.
A syntax error occurs when the parser cannot decide on a valid action to continue parsing, indicating the input does not conform to the grammar.
In shift-reduce parsing, a shift-reduce conflict occurs when the parser's action table suggests both shifting and reducing are possible. Which of the following strategies is commonly used to resolve this conflict in practical parser generators?
Think about how arithmetic expressions are parsed correctly despite conflicts.
Operator precedence and associativity rules guide the parser to choose shift or reduce, resolving conflicts to parse expressions correctly.
