[antlr-interest] Re: trying to understand greedy option
Richard Clark
rd_clark at sbcglobal.net
Tue Aug 3 16:17:47 PDT 2004
I think it would be better to write fields as:
fields
: field (COMA field)*
;
Then a comma unambiguously begins a new field assignment.
The problem with your old declaration:
> fields
> : field (COMA)?
> | field COMA fields
> ;
is that it expands to:
fields
: field
| field COMA
| field COMA fields
;
which is clearly ambiguous. If you turn on "greedy" to clear the
warning, ANTLR will go for the longest match it thinks it can get,
which is "field COMA fields" and will die if you have a trailing comma
without a field assignment following.
...Richard
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list