> Has anyone thought about the pros/cons of adding an infix operator to
> ANTLR? Here's a simple example of what I mean:
> 
> Currently, ANTLR.g3 contains this rule:
> 
> throwsSpec
>         :       'throws' id ( COMMA id )*
>         ;
> 
> Which could be written using a greedy infix operator (represented here
> by %) as:
> 
> throwsSpec
>         :       'throws' (id % COMMA)
>         ;
> 
> 
> I think an operator like this would be interesting, but I'd really like
> to hear some other opinions.

The first problem is that you haven't named the operator. Names make clear what 
an operator does. I've thought of "Alternating operator", but then it seems to 
mean that an id has to come after the COMMA - and vice versa. Interpreting this 
description literally, COMMA may be accepted as the last element.

One could say, that this isn't allowed but then % looks uniform, but doesn't 
behave like this. Contrarily, the current notation confers the allowed input 
correctly. Another problem is that the rewrite rules don't work the same as for 
other rules. Either you use = to mean += or use += in a place without Kleene 
operators (the + and *). Overall, I can't see an argument in favor of adding 
your suggestion in the current form.

Johannes
> 
> Thanks,
> Sam
> 

-- 
Sensationsangebot verlängert: GMX FreeDSL - Telefonanschluss + DSL 
für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K1308T4569a
_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org/mailman/listinfo/antlr-dev

Reply via email to