On 03/02/2011 09:09 PM, The Researcher wrote:
> Does ANTLR 3 have built-in support for matching an exact number or bounded
> number of items that does not rely on using {...}?=>
> 
> e.g for a 32 bit value of four bytes the rule statement would be
>     byte[4]
> 
> or for an a structure that has a bound of elements between 1 and 16 the rule
> statement would be
>     struc[1:16]
> While ANTLR 3 uses [ ] for rule parameters, here [ ] is used to signify
> element bounds.
> 
> I have looked high and low for this, and found nothing tangible.
> 
> Abusing {...}?=> works, but I would like to stop abusing it.

Set up the action code for your rule to count the number of elements
matched.  When you exceed the number you need, have the action output an
error, or raise an exception, or, ....

Or you can abuse gated semantic predicates.

> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
Kevin J. Cummings
[email protected]
[email protected]
[email protected]
Registered Linux User #1232 (http://counter.li.org)

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to