[antlr-interest] Is it possible to tell whether the source orheader is being generated?

Jim Idle jimi at temporal-wave.com
Sat May 26 13:16:02 PDT 2007


The code generator calls the headerFile() template, with the same set of
parameters that outputFile gets, so you will generate your header file
there, which includes any forward declarations, class headers and
function prototypes and that sort of thing. You will know that you are
generating a lexer, parser or tree parser. Then it will call
outputFile() with the same stuff and here you generate your
implementations "static" stuff and actual code.

I found that rather than take a subtemplate and try to work out if this
is the HEADER or main code, it was more obvious to take the subtemplate
and make a new version xxxHeader() as you tend to want to do generate
such different things, that it makes no sense to clutter the subtemplate
with tests of parameters etc.

So, control your header file with new headerfile subtemplates and
remember that headerFile is the start point and controls that file and
outputFile is the main code and it should fall out nicely.


Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Luke A. Guest
> Sent: Saturday, May 26, 2007 9:08 AM
> To: ANTR Interest
> Subject: [antlr-interest] Is it possible to tell whether the source
> orheader is being generated?
> 
> Hi,
> 
> basically, I was just wondering if in any template in the
> <language>.stg
> file it is possible to determine whether the header orthe source is
> currently being generated? i.e. inside lexer()?
> 
> Thanks,
> Luke.
> 



More information about the antlr-interest mailing list