[antlr-interest] tokenVocab and certain rules cause NullPointerException in org.antlr.Tool
Gavin Lambert
antlr at mirality.co.nz
Fri Feb 1 12:42:01 PST 2008
At 06:51 2/02/2008, Erik Kratochvil wrote:
>
>grammar Expr;
>options { tokenVocab = Basic; }
>r: (~S)+;
>S:';';
>W:' ';
[...]
>The funny thing is that if I slightly change the rule *r*, the
>Lexer/Parser is generated without any complaint.
Generally I've found that ~ only works properly in lexer rules,
not parser rules.
>The truly funny thing is that when I remove the tokenVocab
clause
>from the original grammar, the Lexer/Parser is -again- generated
>without any complaint.
No idea about that one :)
Although, since you're making a combined grammar, the options
section applies to both lexer and parser, which might be confusing
things. I'm not sure if this is valid syntax, but try this:
lexer::options { tokenVocab = Basic; }
Failing that, try splitting your grammar into separate lexer and
parser grammars.
More information about the antlr-interest
mailing list