[antlr-interest] Bounded Closures?

Wincent Colaiuta win at wincent.com
Tue Jun 26 13:09:21 PDT 2007


El 25/6/2007, a las 18:01, Johannes Luber escribió:

> 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}?
>   ;
>
> Just adapt this to your needs.

Doesn't the += notation you've used there only work in parser rules?  
I don't think it works in lexer rules.

Cheers,
Wincent



More information about the antlr-interest mailing list