Dashboard > ANTLRMorph > ... > ANTLRMorph Documentation > Morph grammar options and actions
  ANTLRMorph Log In | Sign Up   View a printable version of the current page.  
  Morph grammar options and actions
Added by Leon, Jen-Yuan Su, last edited by Leon, Jen-Yuan Su on Sep 02, 2008  (view change)
Labels: 
(None)

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;
        ...
    }
}
Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.1 Build:#806 May 06, 2007) - Bug/feature request - Contact Administrators