[antlr-interest] literals.
aravind srinivasan
aravinds at convergelabs.com
Wed Dec 10 02:32:54 PST 2003
You can try using syntactic predicate. I am not sure if that would be the correct way of
doing it as i have just started using antlr.
...| ("instanceof") => "instanceof" { rel_op = JSToken.InstanceOf; }
| "in" { rel_op = JSToken.In; }
;
Aravind.
-----Original Message-----
From: cesar octavio lopez nataren [mailto:cesar at ciencias.unam.mx]
Sent: Wednesday, December 10, 2003 6:01 AM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] literals.
On Wed, 2003-12-10 at 01:00, Oliver Zeigermann wrote:
> This looks like you need more lookahead, k=3 should do to distinguish
> "in" from "instanceof".
> "in" : LA(1)=i, LA(2)=n, LA(3)=?
> "instance" : LA(1)=i, LA(2)=n, LA(3)=s
Hello Oliver:
Look, If I put:
relational_op returns [JSToken rel_op]
{ rel_op = JSToken.None; }
: LESS_THAN { rel_op = JSToken.LessThan; }
| GREATER_THAN { rel_op = JSToken.GreaterThan; }
| LESS_EQ { rel_op = JSToken.LessThanEqual; }
| GREATER_EQ { rel_op = JSToken.GreaterThanEqual; }
| "instanceof" { rel_op = JSToken.InstanceOf; } <<<---
| "in" { rel_op = JSToken.In; } <<<----
;
I get the message: jscript.g:573:11: k==1:"in"
Note that on my lexer options I already have: k = 3
If I erase that and add the lexical rule
IN: "in";
I get:
jscript.g: warning:lexical nondeterminism between rules IDENTIFIER and
IN upon
jscript-lexer-parser.g: k==1:'i'
jscript-lexer-parser.g: k==2:'n'
jscript-lexer-parser.g: k==3:<end-of-token>
The definition of IDENTIFIER that I have is:
IDENTIFIER
options { testLiterals = true; }
: ('a'..'z' | 'A'..'Z') ('a'..'z' | 'A'..'Z' | '0'..'9')*
;
what can I do?
Thanks a lot for the help.
César
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list