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

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


Well, would you care to actually ask a question?


> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Umesh Kalappa
> Sent: Tuesday, September 04, 2012 11:10 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Why i need to use LL(*) ????
>
> 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


More information about the antlr-interest mailing list