Factor out repetition handling
Parse counted repetitions