简体   繁体   English

如何使用antlr.jar输出python3目标代码?

[英]How do I output python3 target code with antlr.jar?

I downloaded: 我下载了:

antlr-4.7-complete.jar

to C:\\ANTLR\\ and renamed to C:\\ANTLR\\antlr.jar . C:\\ANTLR\\ C:\\ANTLR\\antlr.jar命名为C:\\ANTLR\\antlr.jar

I also did: pip3 install antlr4-python3-runtime . 我也做了: pip3 install antlr4-python3-runtime

Which I assume is meant for coding with since the download docs here , say: 自从这里下载文档以来,我认为这是为了进行编码,例如:

All users should download the ANTLR tool itself and then choose a runtime target below, unless you are using Java which is built into the tool jar. 除非您使用工具罐中内置的Java,否则所有用户都应下载ANTLR工具本身,然后在下面选择一个运行时目标。

So it looks like I have all the tools required. 因此,看来我具有所需的所有工具。 But doing: 但是这样做:

cd C:\\ANTLR
java -jar antlr.jar arithmetic.g4

Outputs Java code! 输出Java代码!

How do I make it output or convert the output to, Python3 code? 如何使其输出或将输出转换为Python3代码?

Thanks. 谢谢。

Please don't tell me this isn't a programming question. 请不要告诉我这不是编程问题。 There is no other place that would give an answer to this question. 没有其他地方可以回答这个问题。

K, answered my own question: K,回答了我自己的问题:

From here : 这里

antlr4 -Dlanguage=Python3 MyGrammar.g4

So I guess I do something like: 所以我想我要做的是:

java -jar antlr.jar -Dlanguage=Python3 arithmetic.g4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM