[antlr-interest] Repeating output constructs with stringtemplates
Terence Parr
parrt at cs.usfca.edu
Fri Aug 31 08:10:00 PDT 2007
On Aug 30, 2007, at 3:26 PM, Andy Tripp wrote:
> Hoping back onto my "vanilla library code is better than clever
> syntax" soapbox,
Hi Andy. so DSLs are bad? We should all go back to Pascal or
assembly? OO is good, but functional is bad? I can't imagine how
decl(type, names) ::= "<names:{ n | <type> <n>;}>"
is not superior to your code. I have to imagine the emergent behavior
in code. In my template, it says...well, "here's the output". A
document with holes in it. Gotta learn the syntax like you had to
learn Java.
You should also argue against parser generators if you're against
unparser generators ;)
Ter
> void splitUpDeclarations(MyAST decl) {
> MyAST parent = decl.getParent();
> int insertLocation = parent.indexOfChild(decl);
> MyAST type = decl.getChild(0); // first child
> List<MyAST> vars = decl.getChildren(1); // rest of children
> for (MyAST var: vars) {
> MyAst singleDecl = new MyAST(DECL);
> singleDecl.addChildren(type.clone(), var);
> parent.insert(insertLocation, singleDecl);
> }
> }
More information about the antlr-interest
mailing list