|Can this grammar be modified for lookahead of 1 ? firstname.lastname@example.org (1994-08-15)|
|Can this grammar be modified for lookahead of 1 ? email@example.com (1994-08-18)|
|Re: Can this grammar be modified for lookahead of 1 ? firstname.lastname@example.org (1994-08-18)|
|Re: Can this grammar be modified for lookahead of 1 ? David=Cook%Diag%Mfg=Hou@bangate.compaq.com (1994-08-19)|
|From:||email@example.com (Steve Simmons)|
|Organization:||CONVEX News Network, Engineering (cnn.eng), Richardson, Tx USA|
|Date:||Thu, 18 Aug 1994 11:37:04 GMT|
firstname.lastname@example.org (Rahul Bhargava x4596 ) writes:
> I am trying to generate a parser using yacc for the following grammar:
> s -> l (1)
> l -> L i F i e (2)
> i -> A | ACA | CA | AC | C (3)
> e -> C (4)
When you are in state "i", consumed an "A" and have "C" as a lookahead,
it is ambiguous because you don't know whether to reduce the "I" state or
shift the "C". YACC resolves shift-reduce conflicts by shifting.
Therefore, it cannot parse the following string although it is acceptable.
To resolve this, you may wish to try the following:
s -> l (1)
l -> L i F ie (2)
i -> A | ACA | CA | AC | C (3)
ie -> AC | ACAC | CAC | ACC | CC (4)
Create a new production which is the concatenation of the "i" & "e"
Return to the
Search the comp.compilers archives again.