Antlr4如何匹配我不关心的东西

Antlr4如何匹配我不关心的东西,antlr4,Antlr4,我正在开发一个具有阶段的解析器。在每个阶段,它将分析一些数据,并为下一阶段做好准备。输入可能已经为下一阶段准备好了数据。我不想用第二阶段的结构使第一阶段的语法复杂化 或者,如果我有一个如下所示的文件: some complex constructions that I do not care at this phase about specifics but I know that they will not have line starting with < ... ... <

我正在开发一个具有阶段的解析器。在每个阶段,它将分析一些数据,并为下一阶段做好准备。输入可能已经为下一阶段准备好了数据。我不想用第二阶段的结构使第一阶段的语法复杂化

或者,如果我有一个如下所示的文件:

some complex constructions that I do not care at this phase about specifics
but I know that they will not have line starting with < 
...
...

< line: 0 foo bar
< line: 1 blah blah

more constructions

< line: 0 foo bar
< line: 1 blah blah
以及其他所有要在通用未知块中返回的内容。注意:我不希望跳过数据,我希望能够访问它,我只是不想在这个阶段解析它


我的语法应该是什么样的

我的语法应该是什么样的?搜索语法岛antlr4。它非常适合混合语法,如HTML中的Javascript等。它似乎也适合您的情况。
line
    :   SERIALIZE_BRACKET KW_LINE 
        NUMBER        # indent
        .*?           # content 
        ( EOL | EOF ) # the end of the line
    ;