[antlr-interest] ANTLR 3.0 tree construction proposal

Loring Craymer Loring.G.Craymer at jpl.nasa.gov
Tue Feb 1 16:00:07 PST 2005


At 03:24 PM 2/1/2005, John D. Mitchell wrote:
>(A) I like the use of semantic predicates for this.
>
>(B) Is it just me or is the ? at the end of the semantic predicates
>ridiculously hard to see?  I'd love to see that move to be a prefix, i.e.,:
>   ?{...}
>The left edge is (with any non-insane formatting convention) always easier
>for humans to scan and parse.

Actually, sem preds and construction preds are pretty clear in 
context--they are oddly placed for actions.  The right end also fits with 
the closure notation.



>Re: Other Issues that I didn't see addressed in your blog...
>
>(A) Payload games
>
>Hmm... Don't we need to support the ability to treat the payload as e.g., a
>list of payloads?  I.e., I'd like the first payload in the AST node to be
>the e.g., Token but then I want to add annotations that are tied to that
>node (rather than building e.g., a map).

No, because payloads are the unit of attribute manipulation.  You can 
define whatever fields (attributes) you like for payload classes for your 
specific application--just as for heteroASTs in 2.x--but you want a single 
data package at each node.

(C) Tree surgery

>Moving beyond the simplistic cases in (A), all of the interesting work
>being done in tree tranforms is real surgery of the tree.  I.e.,
>transformations which take place across a number of rules working in
>conjunction.

I have support for that hidden in 2.8--I haven't tested it (at the grammar 
level; I used JUnit when developing the support classes), but am not happy 
with my current syntax.  We talked about using attributes for that at the 
cabal, and that has possibilities.  One of the big problems is that this 
adds to the complexity of analysis for tree grammar generation--does the 
calling chain go through ()?, ()*, ()+, and is a tree fragment always 
passed into an insertion point?  That can be messy.


>A couple of areas that come immediately to mind are the need for labelled
>subrules and being able to pass (and use) trees (aka tree fragments) around
>in dynamic attributes (both down/inherited and up/synthesized) and as
>parameters/return values.

I've come around to this way of thinking, myself.  I could have easily 
implemented labeled subrules in 2.8, but didn't see it as a good solution 
at the time.



>(D) Error handling
>
>You haven't gone into how the error handling would work with this.

Eewwww.  You would open _that_ can of worms!

--Loring



>Thanks,
>         John




More information about the antlr-interest mailing list