[antlr-interest] Another update to Honey Badger
Terence Parr
parrt at cs.usfca.edu
Sat Jan 21 21:22:42 PST 2012
Yeah, i think it's very reasonable to expect retargetable grammars now that we can rely less on actions in grammars and hopefully none in lexer.
Ter
On Jan 21, 2012, at 5:45 PM, Kyle Ferrio wrote:
> Ter,
>
> Thank you! This may seem like a small thing, but it really saves time when
> reusing grammars. By making common actions transparent, any special
> actions will stand out.
>
> Kyle
> On Jan 21, 2012 4:43 PM, "Terence Parr" <parrt at cs.usfca.edu> wrote:
>
>> 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
More information about the antlr-interest
mailing list