Child pages
  • Antlr3AdaTarget
Skip to end of metadata
Go to start of metadata

Ada ANTLR v3 Target

Author

Luke A. Guest (Archeia)

Status

Currently dormant.

Old stuff that is no longer relevant, maybe ;)

I currently have a very basic Ada95Target.java file which produces package bodies and specifications using the GNAT filename convention. In conjunction with this, I've taken the Java.stg file from codegen/templates/Java and started to modify this to produce a lexical analyser package.

Currently, a very basic scanner is produced with a tagged type in the specification. This won't compile as there is no runtime and I've not quite decided on how to implement the runtime as yet.

As I'm currently learning ANTLR and StringTemplate, this will probably take some time to achieve.

Runtime

  • Ada95 is strongly typed and the runtime has been implemented in such a way to try to take the Java
    code and enforce restrictions upon the types rather than using int's all over the place.
  • Ada95 doesn't support mutually dependent packages, so this must be avoided at all costs.
  • Also, Ada95 doesn't have support for interfaces, so mix-in inheritance will be used where appropriate.

Package differences from Java to Ada95

Java

Ada95

Comment

IntStream

ANTLR.Stream

Modified to be a generic abstract type so that type checking can
be used on the actual type in the stream.

BaseRecognizer

ANTLR.Root_Recogniser

The word "Root" is more consistent with the Ada runtime library

Method differences from Java to Ada95

Java

Ada95

Comment

LA

Look_Ahead

For reasons of readability

Usage

Compilation

TODO Show how to compile the runtime.

Example

TODO Provide a quick an easy example grammar.

Future work

Ada 2005

I decided not to target Ada 2005 as there is only 1 compiler that support the new standard, and as it's so new, it doesn't do it very well (yet). Ada 2005 would've made the runtime easier to port, as it would be possible to provide an almost 1:1 correlation from Java to Ada.

What does Ada 2005 provide on top of Ada95?

  • Interfaces, a la Java. Yup multiple inheritance of interface types.
  • Mutually dependent packages, finally!
  • Dot notation for tagged types (that's classes in C++/Java speak), this makes it a bit less clumsy, so instead of typing:
ANTLR.Lexer.Match(Self, 'A');

we can write

Self.Match('A');

which is a bit nicer.

  • No labels