tags:

views:

33

answers:

1

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?

+1  A: 

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]

idrosid
Correct: the only way to do this is by editing the code-generator template files for the Java target in this case (`.stg`, if I'm not mistaken).
Bart Kiers