parsing - Ignoring whitespace on a per-parser-rule basis in Antlr4 -
my grammar must ignore whitespaces part, except in contexts. answers this question advises define specific lexer rules handle exceptions want.
the problem (i think) cannot handle such cases @ lexer level, since seem triggered high @ parser level.
to more specific: want recognize like
myrule: myparsetree1 operator myparsetree2 // ws skipped | myparsetree1 ws sensitiveoperator ws myparse // ws carries meaning
keeping in mind have ws -> skip rule because in of grammar whitespaces should skipped.
in xtext, rules can specify on rule-scoped basis hidden tokens apply within rule's scope:
myrule (hidden comments): ... // ws reaches parser, comments don't myrule2 (hidden ws, comments): ... // ws skipped, comments
but clueless antlr4.
if want skip tokens
depending on grammar context should have @ question here given procedure described skipping whitespace (as want it).
Comments
Post a Comment