[antlr-interest] Disambiguating simple grammar – could anyone help?
Tomasz Jastrzebski
tdjastrzebski at yahoo.com
Fri Apr 10 03:43:17 PDT 2009
Hello developers,
I cannot figure out how to disambiguate the following grammar using syntactic predicate, so the range rule takes precedence over the offset rule.
Could anyone advice? I prefer to keep separate range and offset rules because of the custom AST tree construction.
Thanks for any pointers,
Thomas
grammar test;
program : (expression)* ;
expression
:
Identifier ((range) => range)?
| offset
;
range : Integer ('-' Integer)? ;
offset : ('+' | '-') Integer ;
Identifier : ('a'..'z')+ ;
Integer : ('0'..'0')+ ;
WhiteSpace : (' ' | '\t' | '\r\n' | '\r')+ { $channel=HIDDEN; };
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090410/5d06542c/attachment.html
More information about the antlr-interest
mailing list