• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/// \page generate Generating Code for the C Target
2///
3/// \section generate Generating C
4///
5/// Before discussing how we compile or call the generated C code, we need to know how to invoke the C code generator.
6/// This is achieved within the grammar file itself, using the language option:
7///
8/// \verbatim
9options {	language = C;}
10\endverbatim
11///
12/// The code generator consists of a single .java file within the standard ANTLR tool jar, and a code generation template,
13/// used by the StringTemplate engine, which drives code generation for all language targets. In fact you can make copies of the C.stg
14/// and AST.stg templates and make changes to them (though you are encouraged not to, as it is better to provide bug fixes or
15/// enhancements which we are happy to receive requests for and will do out best to incorporate.
16///
17/// If you are working in the Windows environment, with Visual Studio 2005 or later, you may wish to utilize the custom rulefile
18/// provided in the C source code distribution under the <code>./vs2005</code> directory for this purpose. If you are using a pre-built
19/// library then you can also download this rule file directly from the FishEye source code browser for ANTLR3.
20///
21/// In order to use the rulefile, you must adopt the following suffixes for your grammar files, though they are otherwise optional:
22///
23/// <table>
24///
25/// <tr>
26/// <th> Suffix </th>
27/// <th> Grammar should contain... </th>
28/// </tr>
29/// <tr>
30/// <td> .g3l </td>
31/// <td> A lexer grammar specification only. </td>
32/// </tr>
33/// <tr>
34/// <td> .g3p </td>
35/// <td> A parser grammar specification only. </td>
36/// </tr>
37/// <tr>
38/// <td> .g3pl </td>
39/// <td> A combined lexer and parser specification. </td>
40/// </tr>
41/// <tr>
42/// <td> .g3t </td>
43/// <td> A tree grammar specification. </td>
44/// </tr>
45///
46/// </table>
47///
48/// You may also wish to use these suffixes if you are building your projects using Makefiles, as this makes the output deterministic.
49/// However in this case a much better solution is probably to utilize the -depend option of the Antlr tool, which should tell your
50/// Makefile what the grammar files generates, irrespective of its suffix. ANTLR does not care about the actual suffix you use for
51/// your grammar file, so building for multiple platforms is relatively easy.
52///
53/// <b>NOTE:</b> Your grammar source, regardless of suffix must be named the same as the grammar statement within it. Grammar xyz
54/// must be contained within a file called xyz.<i>anything</i>
55///
56///
57
58