如何解决在生成的解析器中ANTLR4产生的编码问题?

时间:2019-05-22 12:42:06

标签: java eclipse-plugin antlr4

我在语法中使用错误替代和消息。问题在于生成解析器时,消息存在编码问题。我该如何解决?

这就是我的语法:

{notifyErrorListeners("À corriger – l'expression ne correspond pas au type de l'attribut");}

这就是生成的解析器所具有的:

notifyErrorListeners("� corriger � l'expression ne correspond pas au type de l'attribut");

1 个答案:

答案 0 :(得分:0)

如果使用最新的ANTLR4版本(4.7.2)进行此操作,请尝试对这些字符使用Unicode转义:

{notifyErrorListeners("\u0192 corriger \u2013 l'expression ne correspond pas au type de l'attribut");}

如果使用的版本低于4.7.2,请先尝试升级。