1

我正在尝试匹配(并忽略)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令牌。我错过了什么?

非常感谢您的帮助。

4

0 回答 0