Yields contiguous MatchObjects of r in s.
    Raises ValueError if r eventually doesn't match contiguously.
341016
def matchiter(r, s, flags=0):
    
    if isinstance(r, basestring):
        r = re.compile(r, flags)
    i = 0
    while s:
        m = r.match(s)
        g = m and m.group(0)
        if not m or not g:
            raise ValueError("{}: {!r}".format(i, s[:50]))
        i += len(g)
        s = s[len(g):]
        yield m
1017406
function r(strings, ...regs) {
  let output = "";
  for (const [i, reg] of regs.entries()) {
    output += strings[i];
    output += reg.toString({ hasUnicodeFlag: true });
  }
  output += strings[strings.length - 1];
  return output;
}
217335
function matches(node, sl) {
    if (!node || node.nodeType !== 1) return false;
    var datas = parse(sl),
      len = datas.length;
    if (!datas[len - 1][0]) return false;
    for (; len--;) {
      if (matchOneData(node, datas[len])) return true;
    }
    return false;
  }
831638
function stringRepeatRep(s, times) {
                var half,
                    val;

                if (times < 1) {
                    val = '';
                } else if (times % 2) {
                    val = stringRepeatRep(s, times - 1) + s;
                } else {
                    half = stringRepeatRep(s, times / 2);
                    val = half + half;
                }

                return val;
            }
298985
def str_matcher(mode):
    

    def f_raw(inp_str, pos):
        return unique_literal_cache_pool[mode] if inp_str.startswith(mode, pos) else None

    def f_collection(inp_str, pos):
        for each in mode:
            if inp_str.startswith(each, pos):
                return unique_literal_cache_pool[each]
        return None

    if isinstance(mode, str):
        return f_raw

    if len(mode) is 1:
        mode = mode[0]
        return f_raw

    return f_collection
709382
def match_handle(loc, tokens):
    """"""
    if len(tokens) == 4:
        matches, match_type, item, stmts = tokens
        cond = None
    elif len(tokens) == 5:
        matches, match_type, item, cond, stmts = tokens
    else:
        raise CoconutInternalException("invalid match statement tokens", tokens)

    if match_type == "in":
        invert = False
    elif match_type == "not in":
        invert = True
    else:
        raise CoconutInternalException("invalid match type", match_type)

    matching = Matcher(loc, match_check_var)
    matching.match(matches, match_to_var)
    if cond:
        matching.add_guard(cond)
    return (
        match_to_var + " = " + item + "\n"
        + matching.build(stmts, invert=invert)
    )
565088
def match_indices(match):
    """"""
    a, b, size = match
    for i in range(size):
        yield a + i, b + i
1219585
def match_subgroup(sequence, pattern):
    """"""

    for element in sequence:
        match = re.match(pattern, element)

        if match:
            yield match.groupdict()
954601
def coll_to_tuples(cls, coll):
        
        if isinstance(coll, basestring):
            raise exc.CollectionCoerceError(
                passed=coll,
                colltype=cls,
            )
        if isinstance(coll, collections.Mapping):
            i = 0
            for k in sorted(coll.keys()):
                yield (i, coll[k])
        elif isinstance(coll, (collections.Sequence, types.GeneratorType)) or (
            hasattr(coll, "next") and callable(coll.next)
        ) or (
            hasattr(coll, "__iter__") and callable(coll.__iter__)
        ):
            i = 0
            for v in coll:
                yield i, v
                i += 1
        elif not coll:
            return
        else:
            raise exc.CollectionCoerceError(
                passed=coll,
                colltype=cls,
            )
251159
def _is_pattern_match(re_pattern, s):
    """"""
    match = re.match(re_pattern, s, re.I)
    return match.group() == s if match else False
719771
def get_nonmatching_blocks(matching_blocks):
    
    i = j = 0
    for match in matching_blocks:
        a, b, size = match
        yield (i, a, j, b)
        i = a + size
        j = b + size
1257128
def _represent_match_traversal(match_traversal):
    """"""
    output = []

    output.append(_first_step_to_match(match_traversal[0]))
    for step in match_traversal[1:]:
        output.append(_subsequent_step_to_match(step))

    return u''.join(output)
565602
def match_case_tokens(loc, tokens, check_var, top):
    """"""
    if len(tokens) == 2:
        matches, stmts = tokens
        cond = None
    elif len(tokens) == 3:
        matches, cond, stmts = tokens
    else:
        raise CoconutInternalException("invalid case match tokens", tokens)
    matching = Matcher(loc, check_var)
    matching.match(matches, match_to_var)
    if cond:
        matching.add_guard(cond)
    return matching.build(stmts, set_check_var=top)
1372601
def dotted_parts(s):
    
    idx = -1
    while s:
        idx = s.find('.', idx+1)
        if idx == -1:
            yield s
            break
        yield s[:idx]
1146511
def bracketedList(l, r, sep, expr, allow_missing_close=False):
  
  # We may need to backtrack for lists, because of list comprehension, but not for
  # any of the other lists
  strict = l != '['
  closer = sym(r) if not allow_missing_close else p.Optional(sym(r))
  if strict:
    return sym(l) - listMembers(sep, expr) - closer
  else:
    return sym(l) + listMembers(sep, expr) + closer
928493
def matches(self, pattern, flags=0):
        
        if not re.match(pattern, self._subject, flags):
            raise self._error_factory(_format("Expected {} to match {}", self._subject, pattern))
        return ChainInspector(self._subject)
648927
def coalesce(self):
        
        self.sort(key=lambda ts: ts.t0.value)
        i = j = 0
        N = len(self)
        while j < N:
            this = self[j]
            j += 1
            if j < N and this.is_contiguous(self[j]) == 1:
                while j < N and this.is_contiguous(self[j]):
                    try:
                        this = self[i] = this.append(self[j])
                    except ValueError as exc:
                        if 'cannot resize this array' in str(exc):
                            this = this.copy()
                            this = self[i] = this.append(self[j])
                        else:
                            raise
                    j += 1
            else:
                self[i] = this
            i += 1
        del self[i:]
        return self