[antlr-interest] Another update to Honey Badger

Christian chwchw at gmx.de
Sun Jan 22 02:05:37 PST 2012


Right. For this reason, it is recommended to use multiple channels
instead of skip(). I think skip() is however useful for memory
optimization cases.

Am 22.01.2012 11:01, schrieb Oliver Zeigermann:
> Ah, thanks for explaining. So when I might need that token later (e.g.
> to spit it out again), I will use channel(HIDDEN), right? Still
> wondering, when would I ever used skip rather than channel(HIDDEN) in
> a grammar, as I may never know if someone reusing my grammar might
> need that token later?
>
> 2012/1/22 Christian <chwchw at gmx.de>:
>> skip() drops the token entirely from the token stream so that it cannot
>> be proccessed after that.
>> channel(HIDDEN) moves it from the token channel 0 (default channel) to
>> the channel 99 (HIDDEN is a constant for that channel number). It can be
>> proccessed afterwards by accessing the hidden channel.
>>
>> Am 22.01.2012 10:44, schrieb Oliver Zeigermann:
>>> Tried it and it works great. I never quite groked when to use
>>> channel(HIDDEN) and when skip, though. Can anyone clarify for me?
>>>
>>> Thanks in advance!
>>>
>>> - Oliver
>>>
>>> 2012/1/22 Terence Parr <parrt at cs.usfca.edu>:
>>>> Hi, I have made an update to Honey Badger to allow special lexer commands to do the usual things without resorting to actions in the target language. This renders lexers almost always language neutral. Without actions in the parser, because of the parse trees, we should be very language neutral for honey badger grammars.
>>>>
>>>> In the lexer, you now have the choice of these commands:
>>>>
>>>>  skip
>>>>  more
>>>>  popMode
>>>>  mode(x)
>>>>  pushMode(x)
>>>>  type(x)
>>>>  channel(x)
>>>>
>>>> You can combine them with a comma and you can only have these commands at the end of an outer alternative:
>>>>
>>>> WS : (' '|'\n')+ -> skip ;
>>>> WS : (' '|'\n')+ -> channel(HIDDEN) ;
>>>>
>>>> CURLY : '{' -> more, pushMode(BLOCKS) ;
>>>>
>>>> You can check it out here on the updated example page:
>>>>
>>>> http://www.antlr.org/wiki/display/ANTLR4/Examples
>>>> http://www.antlr.org/depot/antlr4/main/CHANGES.txt
>>>>
>>>> Download here:
>>>>
>>>> http://antlr.org/download/antlr-4.0ea-complete.jar
>>>>
>>>> I will update the examples soon.
>>>>
>>>> Note that the old-style actions still work; these new commands simply translate to the raw actions. Obviously, if you need to do some logic before sending the token type, you will need to use an action in the target language.
>>>>
>>>> Enjoy,
>>>> Ter
>>>>
>>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>>
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list