I am modifying an already existing ANTLR grammar file to allow a specific comment to be able to be parsed. Currently a Lexer rule exists to filter all comments to the hidden channel. The rule looks like:
COMMENT : '//' .* ('\n' | '\r') {$channel = HIDDEN;};
I would like to modify this rule to allow a comment through if it is //@key
. I attempted to play with negation statements to try and prevent the //@key
statement from matching by using //~('@')
which seemed to work, but there are other //@
tags that I would like to continue to filter to the hidden channel that this statement allowed through.