On Feb 2, 2010, at 4:01 AM, Kay Röpke wrote:
>> Since you are making a clean break from everything v2, maybe (...)#1 --
>> makes the construct read very literally.
>
> What are the semantics of the # operator?
> Allow each alternative exactly once?
> Allow each alternative zero or one time?
yeah,We might also need to say one of those.
> How about making this thing an option, like greedy? For one thing, this use
> case isn't all that common and usually constrained to one or just a few
> rules, like type modifiers or optional blocks like in ANTLR.
not a bad suggestion
> Example:
>
> prequelConstructs
> options { altsMaxOnce = true; }
> : ( ^(o+=OPTIONS .*)
> | ^(i+=IMPORT .*)
> | ^(t+=TOKENS .*)
> )*
> /* wouldn't actually be necessary:
> {BasicSemanticChecks.checkNumPrequels(gtype, $o, $i, $t);} */
> ;
>
> or even better:
>
> prequelConstructs
> : (options { altsCardinality = 1; } : /* could also be > 1, = 0
> would be an error as it couldn't match anything. */
> ^(o+=OPTIONS .*)
> | ^(i+=IMPORT .*)
> | ^(t+=TOKENS .*)
> )*
> /* wouldn't actually be necessary:
> {BasicSemanticChecks.checkNumPrequels(gtype, $o, $i, $t);} */
> ;
or just cardinality=... We'd have to use '>=1' or whatever" because otherwise
we have to introduce arbitrary expression syntax for option values :( I do
like the option idea.
Ter
_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org/mailman/listinfo/antlr-dev