views:

55

answers:

0

I have the following

rule : A B;

A : 'a_e' | 'a';
B : '_b';

Input:

a_b    //dont work
a_e_b  //works

Why is the lexer having trouble matching this? When ANTLR matches the 'a_' in 'a_b' shouldnt it backtrack or use lookahead or something to see it cant match a token A and then decide to match token A as 'a' and then procede to match token B as '_b'?

I think ive missunderstood something very basic about how antlr works. Ive tried to read up on it in the ANTLR doc and google. But i have little experience wokring with lexers and parsers.

Thank you very much for any help.