Re: java parsing problem

"Joachim Durchholz" <joachim_d@gmx.de>
22 Oct 2000 01:24:30 -0400

          From comp.compilers

Related articles
java parsing problem shirleytemple@my-deja.com (2000-10-19)
Re: java parsing problem LLkParsing@aol.com (2000-10-22)
Re: java parsing problem joachim_d@gmx.de (Joachim Durchholz) (2000-10-22)
Re: java parsing problem Ivan_Ivan_Ivan@yahoo.com (Ivan Naumov) (2000-10-22)
| List of all articles for this month |
From: "Joachim Durchholz" <joachim_d@gmx.de>
Newsgroups: comp.compilers
Date: 22 Oct 2000 01:24:30 -0400
Organization: Compilers Central
References: 00-10-146
Keywords: Java, parse

<shirleytemple@my-deja.com> wrote:
>
> Is this left-recursion?


Yes. ("left-recursion" means there's a recursion in the productions that
threads through the leftmost symbol in each production.)


You'll have to rewrite the grammar to make it LL.
A simple-minded rewrite would be to expand productions until you get
something like


    Primary:
        ... -- Other productions 1
        Primary . Identifier
        ... -- Other productions 2
and to rewrite this as
    Primary:
        Simple_Primary
        Simple_Primary . Primary_Sequence
    Simple_Primary:
        ... -- Other productions 1
        ... -- Other productions 2


which is LL.
More intelligent rewrite techniques might exist; the above is textbook
knowledge.


I'm not 100% sure, but I dimly remember that not all LR languages are LL
(and vice versa). If that's the case, I suspect that there's no general
algorithm for transforming an LR grammar into an LL one; grammar
transformations tend to run into undecidability issues pretty quickly.


Regards,
Joachim


Post a followup to this message

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