Related articles |
---|
converting this grammar to LL1 te-cheng_shen@agilent.com (Te-Cheng Shen) (2002-10-20) |
Re: converting this grammar to LL1 chungyc@pobox.com (Yoo Chung) (2002-10-24) |
Re: converting this grammar to LL1 joachim_d@gmx.de (Joachim Durchholz) (2002-10-24) |
Re: converting this grammar to LL1 patrick.volteau@st.com (Patrick Volteau) (2002-10-25) |
Re: converting this grammar to LL1 andreas.gieriet@externsoft.ch (Andreas Gieriet) (2002-10-25) |
Re: converting this grammar to LL1 te-cheng_shen@agilent.com (Te-Cheng Shen) (2002-11-06) |
Re: converting this grammar to LL1 joachim_d@gmx.de (Joachim Durchholz) (2002-11-07) |
Re: converting this grammar to LL1 slk12@earthlink.net (SLK Parsers) (2002-11-12) |
From: | "Yoo Chung" <chungyc@pobox.com> |
Newsgroups: | comp.compilers |
Date: | 24 Oct 2002 23:54:04 -0400 |
Organization: | Stanford University |
References: | 02-10-097 |
Keywords: | LL(1), parse |
Posted-Date: | 24 Oct 2002 23:54:04 EDT |
"Te-Cheng Shen" <te-cheng_shen@agilent.com> writes:
> This is supposed to be really simple but I have worked on it for hours
> but all generated grammar are ambiguous and I am not sure why.
>
> This is the grammar
>
> E->id | &id | (E) | E[int] | E=E
>
> First of all, can this grammar make LL1? I am not sure.
Yes, it is possible.
> Then the resulting grammar is
>
> E-> F = E
> E -> F
> F -> id| & id | ( E ) | E [ int ]
Look at the possible parse trees for "a=b[1]" (there's more than one
with the above grammar). Try to figure out a way to write an
equivalent grammar that has only one parse tree for this string.
--
Yoo Chul Chung <http://www.stanford.edu/people/chungyc>
Return to the
comp.compilers page.
Search the
comp.compilers archives again.