我正在尝试匹配(并忽略)c样式的块注释。对我来说,顺序是(1)/*
,然后是(2)除/*
或*/
以外的任何东西,直到(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 );
}
;
但是Antlr并不像我一样;)
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).
因此错误消息有点含糊,但我认为试图说的是,只能否定范围,单字符替代或令牌替代。但这不是我所拥有的吗? BLOCK_COMMENT_START
和BLOCK_COMMENT_END
都是令牌。我想念什么?
非常感谢您的帮助。