PetitParser: Is there a parser like plus() but with an upper boundary?

66 Views Asked by At

Is there a parser like plus() that has an upper boundary, to model expressions like Item <- [a-zA-Z0-9]{1,5}?

Similarly for something like Item <- [a-zA-Z0-9]{3,5}?

1

There are 1 best solutions below

0
On

Yes, the repeat operator does that:

Parser item = word().repeat(1, 5);

Check the JavaDoc for additional information.