Related articles |
---|
LL to LALR conversion k_stol@hotmail.com (Klaas-Jan Stol) (2003-02-11) |
Re: LL to LALR conversion pjj@cs.man.ac.uk (Pete Jinks) (2003-02-12) |
From: | Pete Jinks <pjj@cs.man.ac.uk> |
Newsgroups: | comp.compilers |
Date: | 12 Feb 2003 12:48:44 -0500 |
Organization: | Computer Science Dept, University of Manchester |
References: | 03-02-064 |
Keywords: | parse, LL(1) |
Posted-Date: | 12 Feb 2003 12:48:44 EST |
Klaas-Jan Stol wrote:
>
> I'm trying to convert some grammar (I think LL(1)) into LALR format.
Any genuine LL(1) grammar is automatically LALR(1).
Unfortunately, your grammar is fundamentally ambiguous
i.e. not LL(1) to begin with. For example, an input of:
a ( (b) (c) )
can be understood in terms of your grammar as:
a functioncall of a with args ( explist ),
where the explist has 2 exps, (b) followed by (c)
or
a functioncall of a with args ( explist ),
where the explist has 1 exp,
which is itself a functioncall of (b) with arg (c)
I think you have incorrectly copied the grammar for Lua, which
uses "," between the expressions in an explist. This resolves
the ambiguity above.
http://www.lua.org/manual/manual.html#BNF
--
Peter J. Jinks, Room 2.99, Department of Computer Science,
University of Manchester, Oxford Road, Manchester, M13 9PL, U.K.
(+44/0)161-275 6186 http://www.cs.man.ac.uk/~pjj
Return to the
comp.compilers page.
Search the
comp.compilers archives again.