[antlr-interest] ANTLR 3.0 tree construction proposal

Jim O'Connor Jim.O'Connor at microfocus.com
Mon Jan 31 08:27:39 PST 2005


Hi Terence,
  I have reactions from my perspective (how can they not be?).  I considered
a few general goals. 
1. What is the learning cost to using Antlr? 

	I use as example "How do I get line numbers from my AST?" In version
2.7.4 and earlier, the necessity of understanding the CommonAST, BaseAST,
Token structure is a barrier to an "educated" user.  Maybe this is a good
thing.
	What is my point?  Tree construction syntax is already a barrier to
overcome to reading Antlr grammars.  To what point is "new/better"
functionality increasing the "learning barrier" for doing simple things?  

Note 1: I haven't used String Template.  Will that be a necessity to
understand Antlr 3.0?
Note 2: I like the effect of ^^.

2. Predicates, Tree construction and actions.
	To use old/current terminology, guessing = 0 means execute an
action.  Consider a rule

Oldstylepredicate :
	a b c => a b c
	| blah blah ;


Assume I have actions on "a", "b", and "c".  These must get executed in
order.

Newstyletree :
	a b c => c c a a b b
	| blah blah ;

The actions on rules "a", "b", and "c" will get executed out of order and
multiple times.  This comment may reveal some strange kind of ignorance.  I
have to be intelligent enough to realize the effect, but stupid enough to do
it.

3. Predicates, Tree construction and actions, again.

	Would it be useful to change the designator from "=>" to something
else?  Again, the "stuff" on the right can be in any order!!!  I guess I am
stuck on the matching order.

4. Missing the whole point.
	The desired effect is to produce a tree that is in the "correct"
order.  This leads to more efficient tree traversal and better ordered
actions in the tree grammar.  The proposal addresses these issues.  Does it
do away with the manual manipulation of the trees?  The imaginary nodes
appears to be a stumbling block.  Or can a @attribute.Imaginary.THISTHING be
created in a header section be used anywhere?

Jim
P.S. Sorry, this is what you get when you're supposed to be doing other work
and "waste" the time considering theoretical Antlr issues.  Hope this is
useful.



> -----Original Message-----
> From: Terence Parr [mailto:parrt at cs.usfca.edu]
> Sent: Sunday, January 30, 2005 6:09 PM
> To: ANTLR Interest
> Subject: [antlr-interest] ANTLR 3.0 tree construction proposal
> 
> Howdy,
> 
> After a lot of typing (and I mean a lot), you'll see my ANTLR 3.0 tree
> construction proposal.  After the proposal, you'll see my long stream
> of consciousness as I wander through the design process (you can
> probably ignore that part).
> 
> http://www.antlr.org/blog/antlr3/trees.tml
> 
> I include a summary of the current opposition to this proposal.  So far
> I have one smart guy for (Sriram Srinivasan has seen an overview of
> this) and one smart guy against (Loring Craymer). ;)
> 
> There are lots of details that will get shaken out when I implement
> whatever we decide, but the broad strokes are there.
> 
> Whew...enough typing for a while.
> 
> Ter
> 
> 
> 
> This message has been scanned for viruses by MailController -
> www.MailController.altohiway.com


More information about the antlr-interest mailing list