如何在antlr4.5

时间:2015-05-28 18:13:34

标签: python antlr4

我正在尝试避免在执行MyParser.py期间报告错误(并恢复)。如何使用这个异常覆盖示例(来自antlr4 book)来实现python目标:

 rule : ...
    ;
    catch[RecognitionException e] {throw e;}

看起来像是这样的:

rule : SOMEDIGIT {print("This guy"); };
except [RecognitionException re] {print ("Everyone happy");}

产生错误:

syntax error: '{print ("Everyone happy");}' came as a complete surprise to me while matching rule preamble

PS。我正在使用antlr4-python2-runtime-4.5

0 个答案:

没有答案