The value in the parenthesis of language expressions signify how many next symbols are needed to make a decision.

For example, without reading a symbol from the input, we cannot decide in LL(1) grammars which rule must be applied for derivation.

In this point, Some thought like that occurs: we can make a decision without reading a symbol from the input in LR(0) grammars for specific derivation.

However, I do not think like that, because we always need an input character in LR(0) parsers. We decide to apply shift or reduce operation by regarding next input symbol. In this case, why is it regarded as LR(0) ?

  • $\begingroup$ The title you have chosen is not well suited to representing your question. Please take some time to improve it; we have collected some advice here. Thank you! $\endgroup$ – Raphael Dec 2 '18 at 21:53

The question to be answered in an $LR(k)$ parse is "has the parse reached the end of a production?" (And if so, which production?)

If we are at the end of a production, we choose a reduce action. Otherwise, we shift the next input whatever it is.

So it should be clear that there are grammars which can be parsed without any lookahead; they are grammars in which no right-hand side is a prefix of a different right-hand side.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.