Is there a way to match a grammar fragment exactly n times similar to FLEX's (...)?{1,n} construct?

Terence Parr

ANTLR currently does not have a {1,n} operator just ?, +, *. It is somewhat of a pain, but I usually just check the count during the semantic analysis or translation phase. In other words, use (...)+ and then count the number you find rather than prescribing how many to find.

There is always a trade-off between how strict your grammar is, how easy it is to write, and how much work you have to do afterwards. For example, to parse C++ you usually are very loose in the parser and very strict in the analysis phase.