Steve B.
Steve B.

Reputation: 57304

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. 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?

Upvotes: 1

Views: 727

Answers (1)

idrosid
idrosid

Reputation: 8029

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]

Upvotes: 1

Related Questions