[antlr-interest] Premature lexer matching
Paul J. Lucas
dude at darkfigure.org
Tue Nov 12 17:19:51 PST 2002
(Hit return too soon for previous post -- sorry.)
Given the following in the lexer:
FOO
: ("foo" "::") => "foo" { $setType( FOO_1 ); }
| ("foo" '(') => "foo" { $setType( FOO_2 ); }
| "foo" { $setType( BAR ); }
;
BAR
: ('a'..'z')+
;
meaning:
1. If "foo" is followed by "::" then it's really a FOO_1.
2. If "foo" is followed by '(' then it's really a FOO_2.
3. Otherwise it's really a BAR.
Given this input:
foobar()
The lexer incorrectly matches just "foo" even though it's immediately followed by non-whitespace text. It should match "foobar" as a BAR.
Why does this not do what I want and how can I fix it?
- Paul
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list