libraries.apt revision 324c4644fee44b9898524c09511bd33c3f12e2df
1Libraries
2
3 The introduction of the import directive in a grammar allows reuse of common grammar files
4 as well as the ability to divide up functional components of large grammars. However it has
5 caused some confusion in regard to the fact that generated vocab files (<<<xxx.tokens>>>) can also
6 be searched for with the <<<<libDirectory>>>> directive.
7
8 This has confused two separate functions and imposes a structure upon the layout of
9 your grammar files in certain cases. If you have grammars that both use the import
10 directive and also require the use of a vocab file then you will need to locate
11 the grammar that generates the .tokens file alongside the grammar that uses it. This
12 is because you will need to use the <<<<libDirectory>>>> directive to specify the
13 location of your imported grammars and ANTLR will not find any vocab files in
14 this directory.
15
16 The .tokens files for any grammars are generated within the same output directory structure
17 as the .java files. So, whereever the .java files are generated, you will also find the .tokens
18 files. ANTLR looks for .tokens files in both the <<<<libDirectory>>>> and the output directory
19 where it is placing the geenrated .java files. Hence when you locate the grammars that generate
20 .tokens files in the same source directory as the ones that use the .tokens files, then
21 the Maven plugin will find the expected .tokens files.
22
23 The <<<<libDirectory>>>> is specified like any other directory parameter in Maven. Here is an
24 example:
25
26+--
27<plugin>
28    <groupId>org.antlr</groupId>
29    <artifactId>antlr3-maven-plugin</artifactId>
30    <version>3.1.3-1</version>
31
32    <executions>
33
34        <execution>
35            <configuration>
36                <goals>
37                    <goal>antlr</goal>
38                </goals>
39                <libDirectory>src/main/antlr_imports</libDirectory>
40            </configuration>
41        </execution>
42    </executions>
43</plugin>
44+--
45
46
47
48