[antlr-interest] Bounded Closures?

Johannes Luber jaluber at gmx.de
Mon Jun 25 09:01:03 PDT 2007


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.

Best regards,
Johannes Luber


More information about the antlr-interest mailing list