2

The question is under the concept of LR parser. Suppose the original grammar is
S->AA
A->aA|b

Is it necessary to add an additional rule S'->S to make it as augmented grammar? In short, I want to know the use of augmented grammar.

Ran G.
  • 20,884
  • 3
  • 61
  • 117
Sharanya
  • 23
  • 1
  • 8

1 Answers1

3

Yes, if you follow the canonical conversion of augmented grammars, a first step is adding a new start symbol $S'$ and the production $S' \to S$, since the algorithm may later "change" $S$.

However, it may not be necessary at all times. If you ask whether or not it is necessary specifically in this case, why don't you try without it and check if you get a valid answer?

D.W.
  • 167,959
  • 22
  • 232
  • 500
Ran G.
  • 20,884
  • 3
  • 61
  • 117