antlr4 - Antlr Lexer exclude a certain pattern -
in antlr lexer, how can achieve parsing token this:
a word contains non-space letter not '.{' inside it. best can come using semantics predicate.
word: wl+ {!gettext().contains(".{")}; wl: ~[ \n\r\t];
i'm bit worried use semantics predicate though cause word here lexed millions of times think put semantics predicate hit performance.
this coming requirement need parse like:
token_one.{token_two}
while token_one can include . , { in letter.
i'm using antlr 4.
you need limit predicate evaluation case following .
in input.
word : ( ~[. \t\r\n] | '.' {_input.la(1)!='{'}? )+ ;
Comments
Post a Comment