[antlr-interest] antlr v4 wish list

Gary Miller gary at sumwise.com
Wed Mar 23 14:06:10 PDT 2011


Hey Jim,

>> - The ability to have actions on the right side of an ast re-write
>> operator.
>
> r: ( alt -> ^(X alt) ) {action} ;

Thanks, I don't recall seeing this anywhere else.
Do you use it often? Or is a bad form?

>> - A different rule @init that only executes during when not
>> backtracking.
>>
>> - The ability to detect / work with an empty scope.
>>   Currently attempts to access an empty scope throws a stack exception
>> (in Java)
>
> That's deliberate as it means you have your scope in the wrong place.
> Getting to an empty scope is a bug in your grammar and you need it to
> abort straight away so that you know how you got there.

The fact that I ran into this is may just be a newbee mistake.
I currently have a walker that does multiple things depending on how
it is called.
The start rule differs inside my application.
I solved the stack exceptions, by redesigning the grammars or using
share global scope.
I'm not sure what my grammars would have ended up looking like if I
could have tested the validity of a scope.
Probably a mute point.

Regards
Gary


More information about the antlr-interest mailing list