[antlr-interest] ignoring auto template construction for now

Loring Craymer lgcraymer at yahoo.com
Fri Apr 4 17:37:08 PDT 2008


Ter--

The solution I implemented in Yggdrasil depends on a few key insights:

1.)   ST output provides real visibility into the input stream (or anidealized, user-friendly. tweaked version of the input stream), and that visibility can be provided to development tools to provide RAD support, not just pretty output but pretty output that makes the tools more usable.
2.)  The ST structuring mechanism is via named slots and is fundamentally different from the tree structuring mechanisms which determine order in an output "stream".
3.)  The proper view for AST versus ST output is not  "either/or" but "and/or".  The printing of intermediate forms should not require a grammar dedicated to template output:  that just prolongs the development process.  Oddly enough, I think that this is the fundamental insight--none of the possibilities I explored "felt right" until I got here.
4.) Heavy duty rearrangement of the input stream should be done through trees; a minimalist syntax for ST support is sufficient.  The first class attributes in Yggdrasil can support major rewrites of template outputs, but I consider that fortuitous; the real benefits are visualization and a more rapid development cycle.

Efficiency is achieved through code generation flags--either the ST generation support is included in the target code generated from a grammar or not.

Cheers!

--Loring



----- Original Message ----
From: Terence Parr <parrt at cs.usfca.edu>
To: antlr-interest Interest <antlr-interest at antlr.org>
Cc: antlr-dev list <antlr-dev at antlr.org>
Sent: Friday, April 4, 2008 3:43:58 PM
Subject: [antlr-interest] ignoring auto template construction for now

Hi. decided it's too hard to get a perfect solution in short order.  i  
easily added auto temp construction but got stuck thinking about  
efficiency and hidden channel stuff.

For now, i realized I can just add this to rules that must return the  
text by default, which suits my purposes with output=template and  
rewrite=true at moment:

@after {
if ( $st==null ) {
    StringTemplate t = %{"<element>"};
    %t.element = $text;
    $st = t;
}
}

Ter






      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080404/69fe5fd6/attachment.html 


More information about the antlr-interest mailing list