[email protected] wrote:
> On 09-08-16 07:08 PM, David-Sarah Hopwood wrote:
>> [email protected] 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

OK, I can reproduce that using
  java org.antlr.Tool bug.g
  javac bug*.java
so we can eliminate ANTLRWorks.


The generated code for mNEWLINE does not contain

    int _channel = DEFAULT_TOKEN_CHANNEL;
    ...
    state.channel = _channel;

as I would expect it to. Someone with a deeper knowledge of ANTLR internals
will have to investigate why not.

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to