[antlr-interest] request for comments on language implementation

Andreas Meyer andreas.meyer at smartshift.de
Wed Feb 25 08:46:34 PST 2009


Hi!

Your mail was addressed to Michael, but I hope it's ok to answer 
nonetheless:

I would consider hand-written code to walk an AST harmful. Maybe there 
are cases where it is useful, but walking a dynamically typed tree like 
this looks like a maintenance nightmare to me. Also, you make yourself 
highly dependent on the underlying tree-model, which changed a lot from 
antlr2 to antlr3.

I share some of your thoughts on tree-grammars: they are not solving 
every problem. But still, they are useful for computing easy properties 
like "contains comparison" or "contains assignment to variable of type 
xxx". I guess what you are looking for is a tool to look for certain 
patterns in a source language, and how to map this pattern to another 
pattern of the same language? Possibly in concrete syntax, with 
placeholders? Yesterday I found a library called MatchO 
(http://wiki.di.uminho.pt/twiki/bin/view/Personal/Joost/MatchO) that 
seems to do just that, but I still have to experiment with it. With some 
modifications, it might even work for antlr3.

Best,
Andreas Meyer

Andy Tripp schrieb:
> Hi Michael,
> Jiffle looks very cool!
>
> A quick "how to compile and run demos" document would be nice.
>
> Now that you've implemented AST rewrites via ANTLR, I'm curious about whether
> you're happy with what you have or whether you think it would have
> been easier to implement by just manipulating the ASTs "by hand"
> (i.e. just manipulate the tree structure in you Java code the way you
> would if ANTLR treewalkers didn't exist).
>
> Here's my take on the issue: 
> http://www.antlr2.org/article/1170602723163/treewalkers.html
>
> I can see already you're no longer a neophyte - I would bet that what you're
> doing is more complicated than most usages of ANTLR.
>
> A small guide to the code would be nice - just explaining how the code is structured
> and maybe an example showing what each of the AST-transform steps is doing.
>
> One issue that comes up occasionally is grammar inheritance.
> For example, you have the exact same definition of expr_op in several of 
> your .g files. So you might want to look into that.
>
> Proving an ant build.xml would be nice.
> And, uhhh, what happened to Morph2.g and Morph3.g?  :)
>
> Andy
>
>   



More information about the antlr-interest mailing list