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

consiliens at gmail.com consiliens at gmail.com
Sun Aug 16 17:25:38 PDT 2009


I looked at ANTLRStringStreams consume() method and noticed that it 
checks for a '\n'. In the current grammar I'm skip()ing newlines, 
instead of placing them on a hidden channel.

I made the following modification to the grammar in ANTLRWorks which 
promptly broke the compiler.
fragment NEWLINE : '\n' '\r'? {$channel=HIDDEN;};
fragment WS      : ('\n'|'\r'|'\t'|' ')+ {$channel=HIDDEN;};

The error message is "cannot find symbol : variable _channel". I edited 
QuizLexer.java and added
public static int _channel; Now when I run the test rig, I can see the 
tokens returned from lexer.nextToken().getText(), although tokens.size() 
still reports zero. This change also enables the debugger to correctly 
parse the input.

Is $channel=HIDDEN not working in ANTLRWorks a known issue? The 404 Not 
Found error for its source code repository does not inspire confidence 
http://fisheye2.cenqua.com/browse/antlrworks.


More information about the antlr-interest mailing list