I am trying to match (and ignore) c-style block comments. To me the sequence is (1) /*
followed by (2) anything other than /*
or */
until (3) */
.
BLOCK_COMMENT_START
: "/*"
;
BLOCK_COMMENT_END
: "*/"
;
BLOCK_COMMENT
: BLOCK_COMMENT_START ( ~( BLOCK_COMMENT_START | BLOCK_COMMENT_END ) )* BLOCK_COMMENT_END {
// again, we want to skip the entire match from the lexer stream
$setType( Token.SKIP );
}
;
But Antlr does not think like I do ;)
sql-stmt.g:121:34: This subrule cannot be inverted. Only subrules of the form:
(T1|T2|T3...) or
('c1'|'c2'|'c3'...)
may be inverted (ranges are also allowed).
So the error message is a little cryptic, but I think it is trying to say that only ranges, single-char alts or token alts can be negated. But isn't that what I have? Both BLOCK_COMMENT_START
and BLOCK_COMMENT_END
are tokens. What am I missing?
Thanks a lot for any help.