[antlr-interest] Simple Grammar breaks ANTLRWorks Interpreter & Debugger?
consiliens at gmail.com
consiliens at gmail.com
Thu Aug 13 13:56:48 PDT 2009
Gavin Lambert wrote:
> At 07:32 14/08/2009, consiliens at gmail.com wrote:
> >I have a simple grammar for quizzes that doesn't work in the
> >debugger, although works fine in the interpreter.
> [...]
> >LETTER : ('a'..'z'|'A'..'Z');
> >INT : '0'..'9'+;
> >NEWLINE : '\n' '\r'? {skip();};
>
> These rules should be marked as fragments, since you're consuming them
> from other lexer rules and not expecting to receive them in the parser.
>
> The general rule of thumb is that you should never define two
> non-fragment lexer rules that can consume the same input, and try to
> avoid doing so when they consume the same common left prefix. (Even in
> the cases where you can get away with having a common left prefix, it
> reduces performance to do so.)
>
>
Thanks for the tip! I marked the appropriate rules as fragments, however
all the issues in the original post still stand. The debugger simply
generates a Parse Tree of root -> quiz, while the Interpreter correctly
generates the Parse Tree. Is this possibly an issue with ANTLRWorks itself?
More information about the antlr-interest
mailing list