[antlr-interest] Bounded Closures?

Terence Parr parrt at cs.usfca.edu
Mon Jun 25 17:58:28 PDT 2007


On Jun 26, 2007, at 2:01 AM, Johannes Luber wrote:

> Randall R Schulz wrote:
>> Hi,
>>
>> Am I correct in believing that the only way to notate bounded  
>> closure in
>> ANTLR is by repeated applications of the zero-or-one (a.k.a.  
>> optional)
>> closure notation?
>>
> ...
>>
>> Did I miss this somewhere, or is the verbose notation the only way to
>> get the effect I need?
>
> For C# I'd write:
>
> fragment
> UnicodeEscape
>   :
>   '\\' ( 'u' | 'U' ) (h+=HexDigit)+ {$h.Count<=6}?
>   ;

Or put that inside the (...)+ to make it stop at 6.

Ter



More information about the antlr-interest mailing list