New answers tagged

0

The augmented grammar adds a new starting non-terminal $S'$ with the sole production $S' \to S$. This helps in detecting acceptance: If you reduce by this particular production (to the non-terminal $S'$), you are accepting. To reduce to the start non-terminal of the original grammar tells you nothing, it might appear on some right hand side.


1

Precedence and associativity declarations are common in parser generators, but they are not part of the theory of context-free grammars. And nor are they part of the working of the LL(k) parsing algorithms (or, for that matter, the LR(k) algorithms). So there is no real way to answer that question in terms of the theory of formal languages. On a practical ...


1

This conflict arises because when the parser is at the beginning of a line and the lookahead is VAR, it can't tell whether or not to reduce an empty maybe_specifier. In this simple grammar, that decision could be resolved with one more lookahead token, making the grammar LR(2), but that might not be true in the original unsimplified version. So the conflict ...


Top 50 recent answers are included