[antlr-interest] lexer problem

Robert Soule robert.soule at gmail.com
Fri Oct 31 14:07:27 PDT 2008


Hi,

I was hoping someone might be able to help me out. I have the following
grammar:

grammar Test;
start: '[' AB ']' | A;
A: '[a]';
AB: ('a' | 'b')+;

In English, there is a keyword in my language '[a]', and
all other statements are of the form: [(a|b)+]. I tried this
with two test cases:

test [ab] fails unexpectedly (no viable alternative)
test [ba] succeeds

I believe that the lexer sees a '[' character followed by
an 'a' characters, and expects a ']' next, even though
'a' or 'b' could also be valid next input characters. Has
anyone had any experience with this type of issue?

thank you,
Robert Soule


More information about the antlr-interest mailing list