The grammar setting of ANTLRMorph inherits the syntax from ANTLR. Currently, morph accepts 3 kinds of setting described as below.
grammar options
The syntax of morph options is identical with the syntax of ANTLR grammar options. However, the option itself is different. Currently morph only accepts 1 option, conforms, which tells morph that the rewrited output language conforms to the input language or not. The value is set to true by default. Therefore, if your output language conforms to your input language, there's no need to set this option.
options { conforms=false; }
morph headers
The use of headers of morph is exactly same as the use of headers of ANTLR grammar. You can set up the package definition here, or add any import statements if necessary.
morph members
You can also add arbitrary actions like constructors, fields or methods in your morph grammar as what you do in ANTLR. Please note that morph sets up a default constructor automatically for passing in a MorphExecuter object pointer.
@member {
MorphExecuter me;
public <grammarName>_morphParser(TokenStream input, MorphExecuter me) {
this(input);
this.me = me;
}
}
Therefore, when you're adding new constrictors, don't forget to set up the MorphExecuter object pointer.
@member {
public <grammarName>_morphParser(TokenStream input, MorphExecuter me, Object obj1, Object obj2...) {
this(input);
this.me = me;
...
}
}