[stringtemplate-interest] Re: [antlr-dev] ST output start/stop tags
Terence Parr
parrt at cs.usfca.edu
Wed Jun 14 09:44:26 PDT 2006
On Jun 14, 2006, at 12:25 AM, Jim Idle wrote:
> That would pretty much do it for me as I found that once I knew which
> template had spat out which piece of code, the rest was easy from
> there.
Yeah, it works pretty well.
> On another note, there will be a need to spit out more than one
> header file
> and perhaps extra C code (or other targets) for additionally
> features I
> would like to add (such as perhaps auto generating a COM interface
> or .Net
> or indeed anything at all really.
Crap...not sure how to handle that...i special case the .hpp file at
this point.
> Do you have any strong preferences for the way to do this. My
> thought is
> that the codegen target .java file could just call any additional
> templates
> it wants when it is called to generate the header file and the
> target file.
As long as we can agree on the data they need, and which template
names, it should work fine.
> However, what method do you wish to adopt (as it should be
> orthogonal across
> all codegens if possible) for signifying that 'extras' are
> requested from
> codegen. I think that it should be some construct in the grammar,
> and it
> probably isn't options. There could be new @ sections etc.
I like using the optional keyword:
optional
headerFile(LEXER, PARSER, TREE_PARSER, actionScope, actions, docComment,
recognizer, name, tokens, tokenNames, scopes, rules,
cyclicDFADescriptors,
bitsets, buildTemplate, profile, backtracking, synpreds,
memoize, numRules, fileName, ANTLRVersion,
generatedTimestamp);
Your Target.java file can ask if headerFile is there
> Before just making something up though, how about you suggest
> something and
> unless I can find something wrong with it, I will just use it. So,
> let's say
> that the C codegen has an option to produce an additional .c and .h
> file for
> some option, such as foobar. What do you think?
Seems ok to me...Currently Target superclass has:
protected void genRecognizerFile(Tool tool,
CodeGenerator generator,
Grammar grammar,
StringTemplate outputFileST)
throws IOException
{
String fileName = generator.getRecognizerFileName();
generator.write(outputFileST, fileName);
}
protected void genRecognizerHeaderFile(Tool tool,
CodeGenerator generator,
Grammar grammar,
StringTemplate headerFileST)
throws IOException
{
// no header file by default
}
Perhaps we should call that 2nd one: genAncillaryFiles() or something.
Ter
More information about the stringtemplate-interest
mailing list