ANTLR get and split lexer content

后端 未结 2 1346
感情败类
感情败类 2021-01-24 17:58

first, sorry about my english, i still learning.

I writing Python module for my framework, which parsing CSS files. I try regex, ply (python lexer and parser), but i fou

2条回答
  •  离开以前
    2021-01-24 18:25

    You should use the ! and ^ AST hints. To make /* not appear in your AST, put ! after it. To control which elements become roots of AST subtrees, append ^. It might look something like this:

    NESTED_ML_COMMENT
    :   COMMENT_START!
        (options {greedy=false;} : (NESTED_ML_COMMENT^ | . ) )* 
        COMMENT_END!
    ;
    

    Here's a question specifically about these operators, which now that you know exist, I hope will be useful: What does ^ and ! stand for in ANTLR grammar

提交回复
热议问题