[antlr-interest] Porting a runtime to Ada

Benjamin Niemann pink at odahoda.de
Tue May 22 04:54:49 PDT 2007


Luke A. Guest wrote:

> On Tue, 2007-05-22 at 13:08 +0200, Benjamin Niemann wrote:
>> 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 take it the capitalisation is necessary, i.e. if I use options
> { language = ada95; } does the directory and template group need to be
> named ada95?

I guess so, but the official convention is to use uppercase labels.

> [...]
>
>> * 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.
> 
> Yeah, I noticed that the Java implementation returns ints (32 bit), do
> all the ports do this? It reads in UTF-8 and transforms it to 32 bit
> characters? In Ada you have Character and Wide_Character.

That's up to your implementation. Python e.g. does not have a 'character'
type. The lexer currently operates on single character unicode strings, but
I'm thinking about switching to ints, if it makes stuff more efficient.
Unicode decoding in Java and Python (don't know about other targets) is done
by the stdlib. You may even start with 8-bit input, if it is sufficient for
your needs and simpler to implement. You'd have to make getMaxCharValue()
in your AdaTarget.java return 255 then.

>> * 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.
> 
> Well, I think it'll be fine up to the parser ;) But that at least should
> be ok-ish.

That's a reasonable goal and not too difficult to achieve.

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/



More information about the antlr-interest mailing list