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

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


I have a simple grammar for quizzes that doesn't work in the debugger, 
although works fine in the interpreter. However, using a * in place of a 
+ breaks it in the interpreter also. At one point it worked in the debugger.

Why does that line, noted in the below grammar, break the Interpreter?

Why doesn't the grammar work in the Debugger? It seems to work fine both 
in the Interpreter and a custom Java test rig running in an IDE outside 
of ANTLRWorks. The debugger only prints a parse tree of root -> quiz, 
with no input shown. When the debugger worked on this grammar, the input 
entered would show up in the Input window.

If there's a better way to write the grammar to fix these issues, I'd 
like to know.

Tested on antlrworks-1.2.3, 1.2.4-SNAPSHOT, 1.3b.

I found some ANTLRWorks code in Hudson and used maven to build the 
SNAPSHOT jar, but the source code link contained in pom.xml 
(http://fisheye2.cenqua.com/browse/antlrworks) is broken with a 404 Not 
Found error. Where is the source code repository for ANTLRWorks?

Thanks for your time.

Sample Input:
1.
*a.
b.

2.
b.
*a.


Grammar:
grammar Quiz;

quiz:
	multiple_choice*;

multiple_choice:
	mc_question responses;

responses:
	// breaks Interpreter causing <epsilon> and <NoViableAltException>
	// (mc_incorrect | mc_correct)*;
	(mc_incorrect | mc_correct)+;

mc_question  : MC_QUESTION;
mc_correct   : MC_CORRECT;
mc_incorrect : MC_INCORRECT;

LETTER 	    : ('a'..'z'|'A'..'Z');
INT         : '0'..'9'+;
NEWLINE     : '\n' '\r'? {skip();};
WS          : ('\n'|'\r'|'\t'|' ')+ {skip();};
MC_QUESTION : INT ('.'|')') .* NEWLINE;
MC_INCORRECT  : LETTER '.' .* NEWLINE;
MC_CORRECT  : '*' MC_INCORRECT;


More information about the antlr-interest mailing list