gpt4 book ai didi

antlr4 - 运行 JSON2XML_ST 时出错

转载 作者:行者123 更新时间:2023-12-04 04:50:38 26 4
gpt4 key购买 nike

我尝试像这样运行 JSON2XML ST:

bab@maz:~/tpantlr2-code/code/listeners$ antlr4 JSON.g4 
bab@maz:~/tpantlr2-code/code/listeners$ javac JSON2XML_ST.java
bab@maz:~/tpantlr2-code/code/listeners$ java JSON2XML_ST t.json
但我得到了:
(json (object { (pair "description" : (value "An imaginary server config file")) ,      
(pair "logs" : (value (object { (pair "level" : (value "verbose")) , (pair "dir" :
(value "/var/log")) }))) , (pair "host" : (value "antlr.org")) , (pair "admin" : (value
(array [ (value "parrt") , (value "tombu") ]))) , (pair "aliases" : (value (array [
]))) }))
Exception in thread "main" java.lang.IllegalArgumentException: No such group file: XML.stg
at org.stringtemplate.v4.STGroupFile.<init>(STGroupFile.java:69)
at org.stringtemplate.v4.STGroupFile.<init>(STGroupFile.java:48)
at JSON2XML_ST$XMLEmitter.<init>(JSON2XML_ST.java:45)
at JSON2XML_ST.main(JSON2XML_ST.java:140)
为什么??有人可以帮我吗?谢谢。

最佳答案

这是一个可以与 JSON2XML_ST.java 一起使用的 XML.stg。源下载仍然不包含 XML.stg。然而,自己提出这个文件是一个很好的学习练习。是给我的。

group XML;

empty() ::= ""

value(x) ::= "<x>"

object(fields) ::= <<

<fields; separator="\n">

>>

enclose_element(x) ::= <<
\<element><x>\</element>
>>

array(values) ::= <<

<values:enclose_element(); separator="\n">

>>

tag(name,content) ::= <<
\<<name>\><content>\</<name>\>
>>

关于antlr4 - 运行 JSON2XML_ST 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17508389/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com