[antlr-interest] Match token {n} times

Bart Kiers bkiers at gmail.com
Sun Aug 28 06:23:15 PDT 2011


Hi Jonne,

No, that is not possible with a quantifier like {x}. You'll have to do it
the "hard" way:

ACCOUNT
  :  NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
  ;

Regards,

Bart.


On Sun, Aug 28, 2011 at 3:20 PM, Jonne Zutt <jonne.zutt.ml at gmail.com> wrote:

> Dear all,
>
> Is it possible with antlr to match a token exactly n times?
> Something like the following:
>
> ACCOUNT : NUMBER{8};
>
> NUMBER  :       ZERO
>        |       (NONZERO DIGIT*)
>        ;
> ZERO    :       '0';
> NONZERO :       '1'..'9';
> DIGIT   :       '0'..'9';
>
> Thanks,
> Jonne.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list