[antlr-interest] ANTLR 3.0 tree construction proposal

Martin Probst mail at martin-probst.com
Mon Jan 31 15:56:37 PST 2005


> 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.

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^)

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.
Maybe use [FOO(args)]? This looks a little bit ambigous with
a:
	b[foo];
b[AST foo]: ...

> That should happen automatically right?  If it doesn't match the first 
> two and you have a blank third, it should continue:
> 
> ( A B =>
> | A C =>
> |
> )
> 
> Stop matching? Or, do you mean "match a production only if not followed 
> by blort"?

Uhm, I think your code does what I meant in the first place. I'll try
and see tomorrow. I once had the impression it somewhat tried to match
one of the rules only matched by syntactic predicates at that time,
though I've done a lot of nasty fiddling with that code block.

Anyway what I read seems like a good improvement from the current stuff,
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 ;-)

Regards,
Martin



More information about the antlr-interest mailing list