Please forgive me if these ideas have been discussed before. I don't remember having read them elsewhere.
For specifying in-rule repetitions, why not use the rule modifer we already have for specifying whole-rule repetitions; namely, C<:x>. Allow :x inside rules like :i and :w, and we get something like this: rx :w/ three m's\: [:3x m] / rx :w/ three to five m's\: [:x(3..5) m] / rx :w/ done at runtime\: [:x($m..$n) m] / It seems straightforward to me, but I admit I don't know how difficult that would be for parsing/compiling purposes. However, it seems too different from :i and :w on some level, to be treated the same. So instead of a match modifier, how about adding a special named assertion akin to C<before> and C<after> called C<x>, that takes an argument: rx :w/ three m's\: <x(3) m> / rx :w/ three to five m's: <x(3..5) m> / rx :w/ done at runtime\: <x($m..$n) m> / Repitition is a kind of assertion, after all, and it seems like it should get to play in the same angle-bracket sandbox as the other assertions. There's already precedent for using C<x> for repetition as a normal operator, and now we have the rule modifier as well, so why not extend it into the rule innards? I confess that I've purposely left out a small detail, and I'm sure you've all noticed: non-greedy matching. I couldn't come up with a way that looked all that nice. I don't know if putting the C<?> after the argument would even work: rx :w/ non-greedy m's\: <x(3..5)? m> / And putting it before the argument (as part of the assertion name?) just looks weird: rx :w/ non-greedy m's\: <x?(3..5) m> / So maybe this proposal is a complete no-go because of non-greediness, but I thought I'd throw it out there anyway because it seemed to me to fit in with assertions rather well, and I like the generalized assertion idea. Kurt