> On Sun, Aug 28, 2011 at 3:20 PM, Jonne Zutt <[email protected]>
> wrote:
>
> > Dear all,
> >
> > Is it possible with antlr to match a token exactly n times?
> > Something like the following:
> >
> > ACCOUNT : NUMBER{8};
> >
>

Hi Jonne,

Bart is correct in that matching a exact quantity is not built in to ANTLR,
and most likely never will. Exact quantities is a feature of Regular
Expressions.

If you are willing to work with gated semantic predicates it can be done.

>From the grammars page http://www.antlr.org/grammar/list download the Java
.class file grammar and take a look at classfile.g; specifically rule for
constant_utf8_info.

I believe it is a older v 2.x grammar but will put you in the ball park.

With this I was able to parse binary files, but eventually took a different
route that didn't use ANTLR.

If you are going to be doing lots of these types of rules in a single
grammar then you should really step back and consider if you want to abuse
ANTLR, and instead take a different approach.

Good Luck,
Eric

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