java - ANTLR 4 $channel = HIDDEN and options -
i need help antlr 4 grammar after deciding switch v4 v3. not experienced antlr sorry if question dumb ;)
in v3 used next code observe java-style comments:
comment : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=hidden;} | '/*' ( options {greedy=false;} : . )* '*/' {$channel=hidden;} ;
in v4 there no rule-specific options. actions (move hidden channel) invalid.
could please give me hint how in antlr v4?
the v4 equivalent like:
comment : ( '//' ~[\r\n]* '\r'? '\n' | '/*' .*? '*/' ) -> channel(hidden) ;
which set single- , multi line comment on hidden
channel. however, if you're not doing these hidden
-tokens, skip
these tokens, this:
comment : ( '//' ~[\r\n]* '\r'? '\n' | '/*' .*? '*/' ) -> skip ;
note tell lexer or parser match ungreedy, don't utilize options {greedy=false;}
anymore, append ?
, similar many regex implementations.
java migration antlr antlr4
No comments:
Post a Comment