[antlr-interest] antlrWorks 1.4.3 - NoViableAltException

Cristian Târşoagă cristian.tarsoaga at gmail.com
Wed Feb 1 05:11:36 PST 2012


Hi everybody,

I try to 'interpret' the following grammar using antlrWorks 1.4.3

grammar test;

//arr : elem*;

elem : (itemA? itemB) => itemA? itemB
 | itemA;
 itemA : SPACE LETTER_A LETTER_A;
itemB : SPACE LETTER_B LETTER_B;

SPACE : ' ';
LETTER_A: 'A'|'a';
LETTER_B: 'B'|'B';


If I try using input text as ' AA', while 'arr' rule is commented, the
'elem' rule is matched.

If I try using input text as ' AA', while 'arr' rule is uncommented, the
'elem' rule fails: I get NoViableAltException.

I don't understand the effect of the 'arr' rule over the 'elem' one (and I
don't even try to match 'arr')

Can somebody help/explain?

Thanks a lot,
Chris


More information about the antlr-interest mailing list