Saturday, 15 September 2012

antlr4 - ANTLR lexer action pushing infos to parser? -



antlr4 - ANTLR lexer action pushing infos to parser? -

i new antlr4 , know best way force info lexer action parser.

i have following:

line_directive: '#line' [ \t]+ integer [ \t]+ string_literal { system.out.println(gettext()); skip(); } ;

basically force gettext() parser.

putting parser-rule line-directive not alternative such line directive can happen everywhere...

thanks help!

communication lexer parser not possible in way want (if understand correctly).

what set line_directive on channel (and not skip token!). there default (or default_channel) , hidden channels, , can introduce more of them 1. parser reads tokens default channel, can alter @ runtime 2.

1 https://theantlrguy.atlassian.net/wiki/display/antlr4/lexer+rules#lexerrules-channel()

2 access channels in antlr 4 , parse them seperately

antlr antlr4

No comments:

Post a Comment