[antlr-interest] simple rules not deterministic

Jim Idle jimi at temporal-wave.com
Tue Oct 9 10:24:52 PDT 2007


I imagine the other rules in you grammar are allowing something akin to:

methodCall methodCall

In that case, the input:

name name

Can either be matched as 'target' and then an optional 'parameter', OR
'target' 'target'. Hence it is ambiguous. It isn’t clear if this is a
problem with the way you have constructed the grammar or a true ambiguity in
the language you are parsing, but hopefully this info will give you the clue
you need to decide :-)

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Mark Volkmann
> Sent: Tuesday, October 09, 2007 10:07 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] simple rules not deterministic
> 
> When I generate code from my grammar I get a warning I don't
> understand that says "Decision can match input such as "NAME" using
> multiple alternatives: 1, 2". This is on the line that defines
> methodCall.
> 
> Here's a snippet of my grammar.
> 
> methodCall: t=target p=parameter* -> ^(CALL $t $p);
> objectReference: 'me' | NAME;
> parameter: variableDef;
> target: objectReference | CLASS_NAME;
> type:	'integer' | 'float' | 'text' | 'yesno';
> variableDef: NAME (':' type)?;
> CLASS_NAME: UPPERCASE_LETTER (LETTER | DIGIT)*;
> NAME: LOWERCASE_LETTER (LETTER | DIGIT)*;
> 
> I see that NAME matches both target and parameter, but target is
> required and parameter is optional. I don't understand why this isn't
> deterministic.
> 
> --
> 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/44ffdba3/attachment.html 


More information about the antlr-interest mailing list