| Usage |
| |
| The ANTLR 3 plugin for Maven can generate parsers for any number of grammars in |
| your project. |
| |
| * Compiling Grammars into Parsers |
| |
| By default, the <<<{{{./antlr-mojo.html}antlr}}>>> goal will search for grammar |
| files in the directory <<<$\{basedir\}/src/main/antlr3>>> and any additional |
| <<<.tokens>>> files in the directory <<<$\{basedir\}/src/main/antlr3/imports>>>. |
| This can be configured to search other directories using the plugin configuration |
| parameters as described in the <<<{{{./antlr-mojo.html}antlr}}>>> goal |
| documentation. |
| |
| The following figure shows the expected layout of files for the default |
| configuration of this plugin. |
| |
| +-- |
| src/main/ |
| | |
| +--- antlr3/... .g files organized in the required package structure |
| | |
| +--- imports/ user-created .tokens files and .g files that are imported by other grammars |
| +-- |
| |
| The next step is to configure your POM to call the plugin. The goals will |
| normally run during the generate-sources phase of the build. Examples of how to |
| configure your POM can be found on the various examples pages, reachable via |
| the page menu. If you stick with the default values, the snippet below will |
| suffice: |
| |
| +-- |
| <project> |
| ... |
| <build> |
| <plugins> |
| <plugin> |
| <groupId>org.antlr</groupId> |
| <artifactId>antlr3-maven-plugin</artifactId> |
| <version>${project.version}</version> |
| <executions> |
| <execution> |
| <id>antlr</id> |
| <goals> |
| <goal>antlr</goal> |
| </goals> |
| </execution> |
| </executions> |
| </plugin> |
| </plugins> |
| ... |
| </build> |
| ... |
| </project> |
| +-- |
| |
| Note that you can create multiple executions, and thus build some grammars with |
| different options to others (such as setting the <<<debug>>> option for |
| instance). |