xref: /aosp_15_r20/external/antlr/antlr3-maven-plugin/src/site/apt/usage.apt.vm (revision 16467b971bd3e2009fad32dd79016f2c7e421deb)
1*16467b97STreehugger RobotUsage
2*16467b97STreehugger Robot
3*16467b97STreehugger Robot The ANTLR 3 plugin for Maven can generate parsers for any number of grammars in
4*16467b97STreehugger Robot your project.
5*16467b97STreehugger Robot
6*16467b97STreehugger Robot* Compiling Grammars into Parsers
7*16467b97STreehugger Robot
8*16467b97STreehugger Robot By default, the <<<{{{./antlr-mojo.html}antlr}}>>> goal will search for grammar
9*16467b97STreehugger Robot files in the directory <<<$\{basedir\}/src/main/antlr3>>> and any additional
10*16467b97STreehugger Robot <<<.tokens>>> files in the directory <<<$\{basedir\}/src/main/antlr3/imports>>>.
11*16467b97STreehugger Robot This can be configured to search other directories using the plugin configuration
12*16467b97STreehugger Robot parameters as described in the <<<{{{./antlr-mojo.html}antlr}}>>> goal
13*16467b97STreehugger Robot documentation.
14*16467b97STreehugger Robot
15*16467b97STreehugger Robot The following figure shows the expected layout of files for the default
16*16467b97STreehugger Robot configuration of this plugin.
17*16467b97STreehugger Robot
18*16467b97STreehugger Robot+--
19*16467b97STreehugger Robot src/main/
20*16467b97STreehugger Robot      |
21*16467b97STreehugger Robot      +--- antlr3/...       .g files organized in the required package structure
22*16467b97STreehugger Robot             |
23*16467b97STreehugger Robot             +--- imports/  user-created .tokens files and .g files that are imported by other grammars
24*16467b97STreehugger Robot+--
25*16467b97STreehugger Robot
26*16467b97STreehugger Robot The next step is to configure your POM to call the plugin. The goals will
27*16467b97STreehugger Robot normally run during the generate-sources phase of the build. Examples of how to
28*16467b97STreehugger Robot configure your POM can be found on the various examples pages, reachable via
29*16467b97STreehugger Robot the page menu. If you stick with the default values, the snippet below will
30*16467b97STreehugger Robot suffice:
31*16467b97STreehugger Robot
32*16467b97STreehugger Robot+--
33*16467b97STreehugger Robot<project>
34*16467b97STreehugger Robot  ...
35*16467b97STreehugger Robot  <build>
36*16467b97STreehugger Robot    <plugins>
37*16467b97STreehugger Robot      <plugin>
38*16467b97STreehugger Robot        <groupId>org.antlr</groupId>
39*16467b97STreehugger Robot        <artifactId>antlr3-maven-plugin</artifactId>
40*16467b97STreehugger Robot        <version>${project.version}</version>
41*16467b97STreehugger Robot        <executions>
42*16467b97STreehugger Robot          <execution>
43*16467b97STreehugger Robot            <id>antlr</id>
44*16467b97STreehugger Robot            <goals>
45*16467b97STreehugger Robot              <goal>antlr</goal>
46*16467b97STreehugger Robot            </goals>
47*16467b97STreehugger Robot          </execution>
48*16467b97STreehugger Robot        </executions>
49*16467b97STreehugger Robot      </plugin>
50*16467b97STreehugger Robot    </plugins>
51*16467b97STreehugger Robot    ...
52*16467b97STreehugger Robot  </build>
53*16467b97STreehugger Robot  ...
54*16467b97STreehugger Robot</project>
55*16467b97STreehugger Robot+--
56*16467b97STreehugger Robot
57*16467b97STreehugger Robot Note that you can create multiple executions, and thus build some grammars with
58*16467b97STreehugger Robot different options to others (such as setting the <<<debug>>> option for
59*16467b97STreehugger Robot instance).
60