Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

All the files in the antlr-3.0/runtime/Java/src/org/antlr/runtime directory are needed to create
a full back-end. You must also copy another group of templates such as antlr-3.0/src/org/antlr/codegen/templates/Java/*.stg. And create antlr-3.0/src/org/antlr/codegen/YourTarget.java if you need to override anything in Target.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.
  • No labels