简体   繁体   English

有没有办法在antlr语法文件中指定Java注释?

[英]Is there a way to specify java annotations in antlr grammar files?

I'm looking for a way to include a few additional strings in output .java files generated from antlr. 我正在寻找一种在从antlr生成的输出.java文件中包括一些其他字符串的方法。 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 (eg class-level annotations) or possibly method annotations? 有没有一种方法可以生成出现在import语句(例如,类级注释)或方法注释之后的字符串?

To the best of my knowledge, you cannot do this. 据我所知,您不能这样做。 The book doesn't mention anything. 本书什么都没提到。 Maybe you can ask at the mail list : antlr-interest@antlr.org 也许您可以在邮件列表中询问:antlr-interest@antlr.org

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

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