[antlr-interest] Re: ANTLR 2.7.4 code gen doc

micheal_jor open.zone at virgin.net
Sat Oct 23 19:06:33 PDT 2004



--- In antlr-interest at yahoogroups.com, Terence Parr <parrt at c...> wrote:
> 
> On Oct 23, 2004, at 9:19 AM, silke7772003 wrote:
> > Hi Terence,
> >
> >> Ok, I think we all want to prevent a 30 day jihad on languages.
> >
> > But perhaps it would be in your interest to give one or another word 
> > to my question about a new output engine. I asked a
> > few days ago what is required to add a code generator for Delphi 
> > (Object Pascal). I got a hint to look at the C#
> > runtime, but this helps only if you know where to start and what must 
> > be implemented.

I may be able to help.

First, the bad news - the ANTLR2.x codegen architecture is a little
clunky. Very unlike the tres cool template stuff arriving with ANTLR3.
Fortunately the three active OO targets (plus the retired Sather and
Python targets) are proof that a Delphi target is definitely do-able.

Right, there are perhaps four tasks minimally to adding a new ANTLR
target language (five if you include porting the examples which I
heartily recommend):
1. Writing the <targetLanguage>CodeGenerator class (about 120kB on
average and you should start with a copy of an existing one - C# or
C++) and a few supporting classes

2. Writing an action.g file for the target

3. Writing/porting the ANTLR runtime for the target language

4. Ensuring the ANTLR tool is aware of your new target, that ANTLR
options apply to your target and, that you implement any
targetLangauge-specific actions.

If you've looked at the C# code generator and runtime (or the C++ one)
you might already have an idea of the size of the generator &  runtime
library. Expect [1] and [3] to take up most of the time and effort. 

If you must (or wish to) generate separate implementation and
interface files (rather than single files as in C# or Java), remember
that the C++ codegen already generates separate *.hpp and *.cpp files.

> > Is there really no document
> > describing the process of creating a new code generator?
> 
> Hi Mike,
> 
> Unfortunately, the situation is bleak for 2.x code generation...very 
> big hassle and no doc other than the other generators.

There is now  ;-)

Micheal
ANTLR/C#






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list