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

consiliens at gmail.com consiliens at gmail.com
Sun Aug 16 18:20:01 PDT 2009


On 09-08-16 07:08 PM, David-Sarah Hopwood wrote:
> consiliens at gmail.com wrote:
>> 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".
>
> That's quite strange; I'm using $channel = HIDDEN in ANTLRWorks (version
> 1.2.3) with no problems. Could something be wrong with your ANTLR/ANTLRWorks
> installation?
>
> Can you reduce the grammar to the minimum necessary to reproduce the above
> error message, and post it here?
>

I tested on ANTLRWorks 1.2.3 also and the same error occurs. I don't 
think there's anything wrong with my ANTLRWorks installation? java -jar 
antlrworks-1.2.3.jar

grammar bug;
bug	:	 EOF;
fragment NEWLINE : '\n' '\r'? {$channel=HIDDEN;};

Console:
[19:14:16] /output/bugLexer.java:50: cannot find symbol
[19:14:16] symbol  : variable _channel
[19:14:16] location: class bugLexer
[19:14:16]             _channel=HIDDEN;
[19:14:16]             ^
[19:14:16] 1 error


More information about the antlr-interest mailing list