## MParse

by

- Stephane Bailliez (sbailliez@imediation.com)

### Requirements

This task requires Metamata Development environment 2.0 freely available at Metamata.

### Description

Invokes the Metamata MParse compiler compiler on a grammar file.

To use the mparse task, set the target attribute to the name of the grammar file to process. You also need to specify the directory containing the Metamata installation using the metamatahome attribute, so that Ant can find the MParse classes.

This task only invokes MParse if the grammar file is newer than the generated Java files. MParse assumes that the Java class name of the generated parser is the same as the name of the grammar file, less the .jj extension.

For additional information about MParse, please consult the online manual available here (PDF)

### Parameters

Attribute | Description | Required
target | The .jj grammar file to process. It will only be processed if the grammar is newer than the corresponding .java file. | Yes
metamatahome | The home directory containing the Metamata distribution. | Yes
verbose | Enable all messages | No
debugparser | Enables parser debugging | No
debugscanner | Enables scanner debugging | No
cleanup | Remove the intermediate Sun JavaCC file created during the transformation of the grammar file. | No. Default to false
maxmemory | Set the maximum memory for the JVM. this is a convenient way to set the -mx or -Xmx argument. | No

### Nested elements

#### jvmarg

Additional parameters may be passed to the VM via nested `<jvmarg>` attributes. `<jvmarg>` allows all attributes described in Command line arguments.

#### classpath

Sets class path (also source path unless one explicitly set). Overrides METAPATH/CLASSPATH environment variables. The `classpath` element represents a PATH like structure.

#### sourcepath

Sets source path. Overrides the SOURCEPATH environment variable. The `sourcepath` element represents a PATH like structure.

### Example

      <mparse target="c:/metamata/examples/parseexamples/javagrammars/singlefile/JavaParser.jj"
              metamatahome="c:/metamata" cleanup="true">
        <classpath>
          <pathelement location="c:/metamata/examples/"/>
        </classpath>
      </mparse>

This invokes Metamata MParse installed in `c:/metamata` on one of the grammar file example `(JavaParser.jj)` and cleans up the intermediate Sun JavaCC file.

Copyright © 2001,2004 The Apache Software Foundation. All rights Reserved.