• retagged by
668 views
0 0 votes
why we are adding augumented grammer in starting of LR(0) grammer??

it's means what is need of augumented grammer? what happed if i'm not adding it if LR(0) DFA constuction???

1 Answer

Best answer
4 4 votes

We are adding augumented Grammar in starting of LR0 parser to make a state where we set as "accept " condition.

To construct a DFA that recognize the viable prefixes we make use of augmented grammar  which is defined as follows 

If $ G=(V,T,P,S)$  is given grammar then the augumented grammar will be as follows:

                           $ G1=(V \cup \left \{ S1 \right \},T,P\cup \left \{ S1\rightarrow S \right \},S1)$.

That is we add a unit production $ S1\rightarrow S$ to the grammar $ G$ and make S1 the new start symbol .The resulting grammar will be augumented grammar.

The purpose of augumented grammar is to make explicitly clear to parser when to accept the string.Parsing will stop when the parser is carrying out the reduction using $ S1\rightarrow S$.

• selected by
Position:
Show:

Related questions

0 0 votes
3 answers 3 answers
4.2k
4.2k views
rahuldb asked Mar 17, 2018
4,225 views
Please anyone create a $LR(0)$ Parsing table on this grammar and show the working of each step:$S' \rightarrow S$$S \rightarrow S$;$A \mid A$$A \rightarrow E \mid id := ...
1 1 vote
1 1 answer
1.1k
1.1k views
vaibhav101 asked Jan 13, 2018
1,065 views
According to my understanding, we LALR is constructed by reducing LR(1) automaton states. So I think it should be LR(1)However, we construct SLR(1) items from the LR(0) a...
1 1 vote
2 2 answers
2.1k
2.1k views
KISHALAY DAS asked Nov 6, 2016
2,061 views
Which states of LR(0) is having conflict..anyone please checkConsider the following grammar:\[\begin{array}{l}\mathrm{S} \rightarrow \mathrm{aSa}|\mathrm{bSb}| \mathrm{A}...
1 1 vote
0 0 answers
171
171 views
Tin_ku asked Aug 2
171 views
We know that the class of languages of LR(0), SLR(1), LALR(1), CLR(1) is the class of DCFLs, with the only exception being that...An LR(0) language is a DCFL that has the...