LL to LALR conversion

Klaas-Jan Stol <k_stol@hotmail.com>
11 Feb 2003 02:13:32 -0500

          From comp.compilers

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)
| List of all articles for this month |

From: Klaas-Jan Stol <k_stol@hotmail.com>
Newsgroups: comp.compilers
Date: 11 Feb 2003 02:13:32 -0500
Organization: Compilers Central
Keywords: parse, question
To: compilers@iecc.com
Posted-Date: 11 Feb 2003 02:13:32 EST

Hi,


I'm trying to convert some grammar (I think LL(1) ) into LALR format.
It's from the Lua language. I have much trouble converting the
following piece (in Yacc format):


%token name
%%
(...)


stat : /* alternatives, not important*/
                          | functioncall
                          ;


functioncall : prefixexp args
                                        | prefixexp ':' name args
                                        ;


prefixexp : var
                                    | functioncall
                                    | '(' exp ')'
                                    ;


args : '(' [explist] ')' /* explist just a list of exp's,
optional (and thus not yacc notation) */
                                | /* alternatives, not important for this */
                                ;


var : name
                        | prefixexp '[' exp ']'
                        | prefixexp '.' name
                        ;


exp : /* some constants, and alternatives */
                        | prefixexp
                        ;


The trouble is that a number of productions is mutual recursive, it's
pretty complicated, as you can see. Does anybody know how to make
this into a LALR(1) grammar?


Regards, K Stol


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.