[antlr-interest] Simple Grammar breaks ANTLRWorks Interpreter & Debugger?

consiliens at gmail.com consiliens at gmail.com
Thu Aug 13 15:12:12 PDT 2009


Gavin Lambert wrote:
> Tracing it through with either the debugger or a unit test should show 
> where the problem lies.  A good thing to try is to write a unit test 
> that simply pulls all the generated tokens off the lexer and verifies 
> them; if your lexer isn't producing the tokens you're expecting then 
> there's little chance the parser will work, and unfortunately the 
> ANTLR/ANTLRworks environment isn't really set up to test the lexer 
> properly.

QuizLexer lexer = new QuizLexer(new ANTLRFileStream(input));
CommonTokenStream tokens = new CommonTokenStream(lexer);
// prints 0
System.out.println(tokens.size());

So according to this there are no tokens, which would explain the blank 
debugger Input window. If the ANTLRWorks Interpreter runs the code 
correctly, why not the Debugger or unit tests?

Any ideas on how to fix the Grammar?


More information about the antlr-interest mailing list