def count_repetitions(self, ctx, maxcount):
count = <NUM_LIT:0><EOL>real_maxcount = ctx.state.end - ctx.string_position<EOL>if maxcount < real_maxcount and maxcount != MAXREPEAT:<EOL><INDENT>real_maxcount = maxcount<EOL><DEDENT>code_position = ctx.code_position<EOL>string_position = ctx.string_position<EOL>ctx.skip_code(<NUM_LIT:4>)<EOL>reset_position = ctx.code_position<EOL>while count < real_maxcount:<EOL><INDENT>ctx.code_position = reset_position<EOL>self.dispatch(ctx.peek_code(), ctx)<EOL>if ctx.has_matched is False: <EOL><INDENT>break<EOL><DEDENT>count += <NUM_LIT:1><EOL><DEDENT>ctx.has_matched = None<EOL>ctx.code_position = code_position<EOL>ctx.string_position = string_position<EOL>return count<EOL>
Returns the number of repetitions of a single item, starting from the
        current string position. The code pointer is expected to point to a
        REPEAT_ONE operation (with the repeated 4 ahead).