[antlr-interest] Writing Delphi Target for Antlr3

Jim Idle jimi at temporal-wave.com
Sun May 27 10:33:55 PDT 2007


I am totally anti macros for anything other than constants in normal C
code - in fact I think these days you are better off using a C++
compiler as a better C, if you can get around the horrible linking
headaches on UNIX ;-).

However, as you will see from comments in the generated code/template,
the one exception is when you are generating code that is not maintained
directly and here you are only concerned with flow really, as the
grammar programmer should not have to debug the C runtime, just single
step the grammar code. 

So: 

STACK_ENTRY(myStack, -2) 

seems a lot more readable than 

ctx->myStackStack->get(ctx->myStackStack, -2 ) 

or whatever it was I had to do to reference back from stack tops. 

As none of the actual C stuff and structures will be too useful for
other targets, then I don't think that would get in the way of its use
as a general template example. However, I think that in order to produce
a target for ANTLR you really need to be someone who can just sit down
and hack your way through it until you understand it, so maybe no
existing template is much use other than for the names and parameters of
the templates themselves and even they are only a starting point.

Jim

> -----Original Message-----
> From: Luke A. Guest [mailto:laguest at archangeli.co.uk]
> Sent: Saturday, May 26, 2007 2:26 PM
> To: Jim Idle
> Cc: Terence Parr; ANTR Interest
> Subject: RE: [antlr-interest] Writing Delphi Target for Antlr3
> 
> On Sat, 2007-05-26 at 13:06 -0700, Jim Idle wrote:
> > functions you have not written yet. I am thinking of producing a C-
> lite
> > output, which does not require runtime and that might help new
> template
> > authors.
> 
> This would be useful as long as it's not chocfull of macros, they make
> things a lot harder to understand. Maybe a Pascal version as it's more
> structured? Or possibly some other lite language? Maybe D-lite?
> 
> > What you are looking for here, as I think you have realized is the
> > equivalent of this in C:
> >
> > {
> > 	int x;
> > 	{
> > 		int y;
> > 	}
> > }
> >
> > It's been some time since even looked at a Pascal program, but does
> it
> > allow:
> >
> > var
> >   x: Integer;
> >   begin
> > 	var
> > 	 y: Integer;
> > 	begin
> > 		...
> > 	end
> >   end
> >
> > ?
> 
> Yeah, I thought Pascal could do it, it's been so long, I coutldn't be
> sure. But the fact that Ada is Pascal like, it makes sense that it
> should be able to do that.
> 
> Thanks,
> Luke.
> 



More information about the antlr-interest mailing list