[antlr-interest] Why i need to use LL(*) ????

Jim Idle jimi at temporal-wave.com
Wed Sep 5 02:02:42 PDT 2012


No

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Umesh Kalappa
> Sent: Wednesday, September 05, 2012 12:01 AM
> To: Jesse McGrew
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Why i need to use LL(*) ????
>
> Hi jesse,
>
> Just wondering in this case then ,Could i say that LL(*) = LALR(*)
> ?????
>
> Thanks
> ~Umesh
>
>
> On Wed, Sep 5, 2012 at 12:14 PM, Jesse McGrew <jmcgrew at gmail.com>
> wrote:
>
> > As it says, "If you have actions at ID, you can't easily refactor."
> >
> > Consider this version of the original with actions added:
> >
> > func : type ID {System.out.writeln("A");} '(' arg* ')' ';'
> >      | type ID {System.out.writeln("B");} '(' arg* ')' '{' body '}'
> >      ;
> >
> > How would you implement those actions in your left-factored version?
> > Moving them to after the arg* might not be acceptable.
> >
> > Jesse
> >
> > On Tue, Sep 4, 2012 at 11:10 PM, Umesh Kalappa
> > <umesh.kalappa0 at gmail.com>
> > wrote:
> > > Hi Group ,
> > >
> > > This is regrading about the  new feature that ANTLR v3 introduced
> > > called
> > >  LL(*) Parsing i.e
> > >
> > >
> > > Natural grammars are sometimes not LL(k) for any fixed k even if
> the
> > > k is usually small; e.g. C function declarations vs definitions.
> > > From the left edge, the lookahead is not fixed to see the ';' vs
> '{'
> > > to distinguish the
> > > cases:
> > >
> > > func : type ID '(' arg* ')' ';'
> > >      | type ID '(' arg* ')' '{' body '}'
> > >      ;
> > > We need arbitrary lookahead because of the arg*. If you have
> actions
> > > at
> > ID,
> > > you can't easily refactor. The lookahead will be 5<=k<=10 usually
> > > for
> > this
> > > decision.
> > >
> > > Here ,in the above example ,i can left factor out the grammar then
> > > using
> > > LL(*) , which is more efficient like
> > >
> > > func : type ID '(' arg* ')' funcelse
> > >      ;
> > > funcelse:';'| {' body '}'
> > >      ;
> > >
> > > Any inputs regrading this ??
> > >
> > > Thanks
> > > ~Umesh
> > >
> > > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > > Unsubscribe:
> > http://www.antlr.org/mailman/options/antlr-interest/your-email-
> address
> >
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list