[antlr-interest] Porting a runtime to Ada
Benjamin Niemann
pink at odahoda.de
Tue May 22 04:08:20 PDT 2007
Hi,
Luke A. Guest wrote:
> I take it all the files in the
> antlr-3.0/runtime/Java/src/org/antlr/runtime/ directory are needed to be
> ported for a full back-end?
Plus antlr-3.0/src/org/antlr/codegen/templates/Java/*.stg and perhaps create
an antlr-3.0/src/org/antlr/codegen/Ada95Target.java
But it is in fact pretty easy to get started:
* In src/org/antlr/codegen/templates/
- create a directory Ada95
- copy Java/Java.stg to Ada95/Ada95.stg
* I recommend building the ANTLR tool 'in place'. Do not create a jar or
compile/copy to a build directory. When you run it with 'java -cp
path-to-src-dir ...' it will use the original *.stg file, which you'll edit
a lot - so rebuilding the tool would be quite a PITA.
* Create a directory antlr-3.0/runtime/Ada95. Here you can put anything you
need (no need to clone Java 1:1).
* Start with a simple lexer like:
lexer grammar T;
options { language = Ada95; }
ZERO: '0';
* Look at the generated code and try to figure out which templates in
Ada95.stg you have to port to get valid Ada95 code. What I did, is to
comment out the Java code in all templates replacing it with something like
FIXME([number]). Then you fix the templates until no FIXME remains in the
output.
* You'll need a basic implementation of a character stream and base
recognizer/lexer to get the example running. Just implement the methods
that are actually needed to get the example running w/o errors.
* You'll either get the feeling "Wow, that was easy!" and move on (that
happened to me) or "Eeek, what a pain!" and let someone else to the work.
:)
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
More information about the antlr-interest
mailing list