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

Posted by Steve B. on Stack Overflow See other posts from Stack Overflow or by Steve B.
Published on 2010-06-11T20:50:16Z Indexed on 2010/06/11 20:52 UTC
Read the original article Hit count: 161

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about java

Related posts about antlr