[antlr-interest] New article on StringTemplates and Treewalkers
Terence Parr
parrt at cs.usfca.edu
Sat Jan 14 11:30:12 PST 2006
On Jan 12, 2006, at 7:43 AM, Andy Tripp wrote:
> I'm not following you exactly, but I think it's a reasonable
> question. I don't buy that I could, for example,
> use StringTemplate to output C# instead of Java, without major
> changes to my code.
I believe you have the controller and view entangled so it would be
hard. I have separated things with ST. All declarative systems seem
to have pattern->pattern which necessarily tangles things; you'd have
to cut-paste all of your this->that patterns to change the that.
icky code duplication I'd argue. ;)
ANTLR v3 is doing very well at separation so far I feel. I have
people working on or potentially will work on targets as follows:
Java: uncle T
C++: Ric
C#: Michael / Kunle??
C: Jim Idle
Objective-C: Kay Roepke
Python: Marq Kole?, Wolfgang Hafelinger?
Ruby: Martin Traverso;
LISP: somebody is exploring this at the moment
Parrot vm compiler: Bernhard Schmalhofer
PhP: Ryan King
Note that I had bytecodes generated for the cyclic DFA for a while.
Also note that C and Obj-C targets are very far along as far as I can
tell. C has a lot more work to do than Java, trust me. So far no
one has asked for anything to be done to code generator minus some
attributes I forgot to push in.
> I don't think
> ANTLR could output MS or Haskell (or Lisp) without major changes.
> ST is not fullfilling the
> "separate your view from your translation" promise in any cases
> other than the most trivial, contrived cases
While I've not done Lisp yet, I'm pretty sure my experience and
intuition should count for something when I say I'm certain I could
make this work. What do you base your assertion on? It *seems* like
it would be hard? Because the order of the way you define things is
different? Until I find a construct that I couldn't generate with my
code generator in multiple back-ends, I must assume it simply
*appears* to be very difficult. No offense. :)
If I knew lisp well, i'd just go build it ;)
> (or when the output languages are so similar as C++/Java/C# and the
> domain is so limited as in the case
> of all the code that ANTLR spits out).
This limitation you speak of is speculation until either we get a
lisp or other weird target or you provide an example that cannot be
done to save us the trouble. ;)
>> With some constraints, I think this is possible.
>>
>
> OK then, what is the Java equivalent of "memset (111, 222, 333);"?
> I suppose that's a constraint :)
Depends on how natural you want the translation as I think you
correctly pointed out ;)
Ter
More information about the antlr-interest
mailing list