[antlr-interest] Common Prefix question

Alexander Kaiser alexander.g.kaiser at gmail.com
Mon Nov 7 12:56:01 PST 2011


Hi,

I am new to antlr (antlr3) and struggling with lexing common prefixes.
My simple grammar:

grammar simple;


R : 'R';
E : 'e';
D : '1';
RESULT : 'Result';


expr : ( RESULT | R E D )  EOF;


On input 'Result' I expect token RESULT, and on input Re1 I expect tokens R
E D but input 'Re1' only throws NoViableAltException.
I searched for info 'antlr common prefixes' on the web and tried increasing
k, lookahead predicates ..., things like

RESULT options{filter=true;} : 'Result';



, but to no avail. I would be very much obliged if anyone could give me a
hint.



-- 
Alexander


More information about the antlr-interest mailing list