Grammatica can be run from Apache Ant. In order for Apache to find the Grammatica task, however, a simple task declaration is required. An example of such a task declaration is present in the figure below:
<taskdef resource="ant-grammatica.properties"
classpath="grammatica-1.6.jar" />
Figure 2.
The Ant task declaration needed to make the
grammatica task available.
The <grammatica> task allows the following
attributes:
The grammar processing is defined in one or more subelements,
such as <csharp>, <java>,
or <validation>. At least one such subelement
must be present, but multiple elements are also allowed.
The <csharp> subelement controls the C#
source code generation. It allows the following attributes:
The <java> subelement controls the Java
source code generation. It allows the following attributes:
dir directory.
The <visualbasic> subelement controls the
Visual Basic.NET source code generation. It allows the following
attributes:
The <validation> subelement allows for
different tests and validations of the grammar and/or data files.
It allows the following attributes:
A simple example of how to use the Grammatica Ant task is shown in the figure below.
<taskdef resource="ant-grammatica.properties"
classpath="grammatica-1.6.jar" />
<grammatica grammar="simple.grammar">
<java dir="src"
package="com.test.simple"
public="true" />
</grammatica>
Figure 1.
A piece of simple Ant code for using Grammatica create
a Java parser for simple.grammar.