[antlr-interest] ANTLR 3.0 tree construction proposal

Terence Parr parrt at cs.usfca.edu
Mon Jan 31 17:28:26 PST 2005


On Jan 31, 2005, at 3:56 PM, Martin Probst wrote:
>> First note that ^(..) and ^[...] are the things you say you didn't 
>> like
>> (except with # instead of ^) ;)
>
> Well no, I said (or meant to say) I didn't like it in curly braces.

  Agreed.  I'm trying to get everything out of actions.

> a!:
> 	b:myB c:myC foo:myD { #a = #(#foo,#(#[FOO],#b,#c)); }
>
> Is not really intuitive. How would this translate to the new scheme?
>
> a:
> 	^(^(FOO[]^ myB myC) myD^)

It would become:

a : myB myC myD -> ^(myD ^(FOO myB myC))
    ;

How does that look to you?  Looks good to me. :)  About as clean and 
straightforward as you can get.

Loring, what would your inline solution look like?  Should just need a 
^[FOO]^ or something, right?

> If you take node construction out of the {} actions it should be 
> clearly
> visible that it's an "imaginary" constructed node and not being 
> matched.

Yes, there can be an ambiguity with respect to referencing elements.

> Maybe use [FOO(args)]?

Yes, i was thinking that FOO is actually shorthand for FOO[] with no 
arguments.  FOO[args] would call a different constructor the default 
constructor (factory method actually).  So if you have

a : FOO -> ^(FOO[] FOO) ;

you get

FOO
  |
FOO

where the top FOO is an imaginary node.  Just my first thought.

> Anyway what I read seems like a good improvement from the current 
> stuff,

Hooray!

> at least to me. I'm going to bed now as it's 1 AM in Good Ol' Europe,
> have a good night and ship ANTLR 3 soon ;-)

Sleep well!

Don't worry.  I'm working my ass off on ANTLR 3. :)  Once I nail down 
what the tree stuff looks like, I can implement quickly and then start 
cleaning up the tool for release and efficiency.  The runtime for ANTLR 
parsers/lexers is currently 22k in a jar. :)  The tree stuff will add 
some, but not that much really.  Maybe 3000 lines total of Java code.

Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com





More information about the antlr-interest mailing list