[antlr-interest] stringtemplate & tree walkers
Arnulf Heller
aheller at gmx.at
Tue Jun 16 09:59:54 PDT 2009
hi there,
are there any complex examples of tree walkers emitting stringtemplates?
What I want to do is to generate C++ header and implementation files
with forward declarations etc
This means that names might show up in multiple places in the resulting files.
here is a small example:
walker:
module
: ^(R n=IDENT) -> R(name={$n})
;
header file:
#include "<R>.h"
class <R>; // ok, no one would do that ...
class <R> : public <R>
{
R r1;
R* r2;
};
I know that I can build up data structures in the walker, finally
triggering a global stringtemplate (as far as I know this is what
happens in the ANTLR backend).
The stringtemplate in this case would look pretty much like the
header file above.
But how can I do that with the "->" semantics in the walker? Do I
need multiple passes then, replacing the string template group file
and collecting the results afterwards?
thx
More information about the antlr-interest
mailing list