[antlr-interest] simple rules not deterministic

Bruce Pierson bpierson at theglobal.net
Tue Oct 9 10:42:01 PDT 2007


In addition to what I said before:

The whole thing should look like this:

methodCall: t=target p+=parameter* -> ^(CALL $t $p*);

Notice the '*' after the $p

--Bruce

-----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 11: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.



More information about the antlr-interest mailing list