有没有办法在antlr语法文件中指定java注释?
我正在寻找一种方法,在从 antlr 生成的输出 .java 文件中包含一些附加字符串。是否有可用指令的完整列表?例如,给定解析器输出如下:
package com.foo.bar; //<-- this can be generated with @header { .... }
//antlr generated
import org.antlr.runtime.*;
...
//<-- is there a way to generate anything here?
public class MyParser {
//<--- or here?
public void f1(){ ... }
}
有没有办法生成出现在导入语句(例如类级注释)或可能的方法注释之后的字符串?
I'm looking for a way to include a few additional strings in output .java files generated from antlr. Is there a comprehensive listing of available directives? For example, given parser output like this:
package com.foo.bar; //<-- this can be generated with @header { .... }
//antlr generated
import org.antlr.runtime.*;
...
//<-- is there a way to generate anything here?
public class MyParser {
//<--- or here?
public void f1(){ ... }
}
Is there a way to generate strings that appear after the import statements (e.g. class-level annotations) or possibly method annotations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,你不能这样做。 书没有提及任何事情。也许您可以在邮件列表中询问:[电子邮件受保护]
To the best of my knowledge, you cannot do this. The book doesn't mention anything. Maybe you can ask at the mail list: [email protected]