[antlr-interest] Fixing grammar rule with trailing optional token

Terence Parr parrt at jguru.com
Fri Jan 17 15:16:04 PST 2003


On Friday, January 17, 2003, at 02:50 PM, angryal2000 
<angryal2000 at yahoo.ca> wrote:

> I am having difficulty trying to fix the following rule:
>
> data_type: FLOAT (OPENBRACKET INTEGER CLOSEBRACKET)? ;
>
> FLOAT="float";
> OPENBRACKET='(';
> CLOSEBRACKET=')';
> INTEGER=('0'..'9')+;
>
> e.g.
> "float" is accept by the rule data_type
> as is
> "float(23)"
>
>
> i know my rule is wrong, i am just not sure how to go about fixing it.
>  any ideas?  thanks.

We'll need more data to help.  For example, is float(23) legal as a 
data_type or not?  Are you getting a nondeterminism warning?  I suspect 
that whoever is calling data_type can also match (... afterwards and 
you are getting a warning.  Is that it?

Terence
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Lecturer in Comp. Sci., University of San Francisco


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list