[antlr-interest] StringTemplate for target Language

Mark Wright markwright at internode.on.net
Thu Apr 8 05:37:35 PDT 2010


On Wed, Apr 07, 2010 at 12:26:27AM +0000, Gouasmi Thouraya wrote:
> Is it obligatory to download and to install Maven2 to create the stringTemplate of a language target?

Yes.

> otherwise what tool use to write the stringTemplate and how?
> please help me
 
Its necessary to download the ANTR 3.2 source code:

http://antlr.org/download/antlr-3.2.tar.gz

and build it with Maven.  The build instructions are in the
file BUILD.txt.  In the mail archives for this list there is a
recent email from myself giving some more hints on building
it with Maven.

Then there are some hints to get started on:

http://www.antlr.org/wiki/display/ANTLR3/How+to+build+an+ANTLR+code+generation+target

So after reating the simple lexer, you build it with the ANTLR tool
as described in the ANTLR documentation, something like:

java -Xmx512m -classpath $(ANTLR_CLASSPATH) org.antlr.Tool -Xconversiontimeout 1200000 -report T.g

please see the ANTLR documentation on how to set the ANTLR_CLASSPATH.

It will generate files like T.XYZ, or TLexer.XYZ and TParser.XYZ.

The XYZ.stg string template you are creating can generate the target
code with whatever strategy you like that makes sense in your target
language.

It may also be necessary to create a
antlr-3.2/tool/src/main/java/org/antlr/codegen/XYZTarget.java
file to customize the information that is passed from the
ANTLR tool to the XYZ.stg string template.



More information about the antlr-interest mailing list