[antlr-interest] simple rules not deterministic

Jim Idle jimi at temporal-wave.com
Tue Oct 9 13:12:40 PDT 2007


Take a look at the Wiki entry regarding predicates. This is really just
saying to look ahead in the tokens and if the rule parameter can be matched,
then definitely match it there. It was probably doing this by default, but
you don’t want the warning of course.

Jim

> -----Original Message-----
> From: Mark Volkmann [mailto:r.mark.volkmann at gmail.com]
> Sent: Tuesday, October 09, 2007 12:11 PM
> To: Jim Idle
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] simple rules not deterministic
> 
> On 10/9/07, Jim Idle <jimi at temporal-wave.com> wrote:
> >
> > Mark,
> >
> > With the full grammar, I can confirm that your issue is what I said.
> In that
> > the rule block has statement+ and this means that your methodCall can
> see
> > the same input in two different ways, being one call to it or two
> calls to
> > it.
> >
> > You can try to rejig the grammar or use a predicate to get rid of the
> > warning, though I bet if you look at the code it is probably doing
> what you
> > 'expect' anyway. Warnings are not good to leave hanging about of
> course.
> >
> > Try:
> >
> > methodCall: t=target ((parameter)=>p+=parameter)* -> ^(CALL $t $p*);
> 
> That fixed it! Thanks!
> 
> I can't say I understand it yet though. Can you explain what this part
> means?
> 
> ((parameter)=>p+=parameter)*
> 
> How does that differ from the following?
> 
> p+=parameter*
> 
> --
> R. Mark Volkmann
> Object Computing, Inc.
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.488 / Virus Database: 269.14.5/1058 - Release Date:
> 10/8/2007 4:54 PM
> 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.488 / Virus Database: 269.14.5/1058 - Release Date: 10/8/2007
4:54 PM
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071009/0ff170ee/attachment.html 


More information about the antlr-interest mailing list