[antlr-interest] ANTLR 3 and StringTemplate

Scott Amort jsamort at gmail.com
Sat Jul 22 12:40:19 PDT 2006


Hi All,

I am quite looking forward to ANTLR 3, and I am looking for a bit of advice.

Currently, I am working on a project that translates a textual musical
representation into graphical output.  The project will consist of a
lexer/parser in a shared library (currently almost finished implementing
with ANTLR 2); a second shared library that will actually perform the
computations necessary to properly layout the graphical representation;
and ultimately, a graphical front-end to display (and manipulate) the
end result.  For now, the development is focused on the first two
libraries (both to be implemented in C++), and a simple command-line
application is being used to co-ordinate and test.

Somewhat tangentially, it would also be beneficial to be able to convert
the textual representation to other text-based formats.  This would seem
to be exactly what StringTemplate is designed for, but I have a few
questions.

I see that StringTemplate uses only Java, C# or Python.  Can I have it
interact with my C++ ANTLR 2 parser library?  For example, can I write
some Python code that will obtain a data structure from the parser
library and then use StringTemplate to obtain the correct output?  I
know that C++/Python interoperability is theoretically possible, but I
am wondering if anyone using StringTemplate has any direct experience
with this option.  I have looked at a few StringTemplate examples, but
they seem to generate both the data and the output template, instead of
obtaining the data from an external source.

The main issue seems to be language choice - C++ will be the main
development language for this project (except for the graphical
front-end, which will likely be C#/Mono), and I am unsure as to whether
it is either possible and/or desirable to mix languages to obtain the
benefits of StringTemplate.  Should I instead just implement an
alternative in C++ (although this seems like reworking the wheel
considering how useful StringTemplate appears to be)?  Finally, will
ANTLR 3 with its use of StringTemplate offer any solutions?

Thanks for any assistance!

Best,
Scott


More information about the antlr-interest mailing list