Add an explicit repetition limit

This matches the behavior of Python and Ruby, which also limit
repetitions.