Re: how to deal with left recursive?

Hans-Peter Diettrich <DrDiettrich1@aol.com>
Sat, 07 Nov 2009 00:25:44 +0100

          From comp.compilers

Related articles
how to deal with left recursive? vincent.feng@yahoo.com (vincent Feng) (2009-11-05)
Re: how to deal with left recursive? kkylheku@gmail.com (Kaz Kylheku) (2009-11-06)
Re: how to deal with left recursive? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-11-07)
| List of all articles for this month |
From: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: Sat, 07 Nov 2009 00:25:44 +0100
Organization: Compilers Central
References: 09-11-018
Keywords: C, parse, LL(1)
Posted-Date: 06 Nov 2009 21:13:51 EST

vincent Feng schrieb:


> I have found ansi c yacc grammar.
> A production of statement list like this
>
> statement_list
> : statement
> | statement_list statement
> ;
>
> is left recursive.
> How to elimilate left recursive in such case?


    statement_list
                    : statement
                    | statement statement_list
                    ;


or shorter EBNF:


    statement_list
                    : statement [ statement_list ]
                    ;
or


    statement_list
                    : statement { statement }
                    ;


> Is there exist a solution for parsing such grammar using LL(k) ?


The C language is essentially LL(1), with one or two LL(2) cases.


DoDi



Post a followup to this message

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