How to tokenize Java8 program using antlr -


currently using java8.g4 of java 8 repo: https://github.com/antlr/grammars-v4

however, wondering how can modify java8.g4 file to make sure if encounter multiple new lines tokenize 1 of them?

refer to: parsing newlines, eof end-of-statement marker antlr3, can add new line parse tree (by adding newline: ('\r\n'|'\n'|'\r') .g4 file. however, if have multiple new lines, multiple lines parsed , added tree not want.

hope can me out!

thanks

i guess mean whitespaces not kept in token list produced lexer, right? happens when whitespaces skipped in grammar. check e.g.

ws: [ \t] -> skip; 

and change to

ws: [ \t] -> channel(hidden); 

this way whitespaces kept on hidden channel , can read them via commontokenstream instance, not in way (just skip).


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -