MCPcopy Index your code
hub / github.com/RustPython/RustPython / __init__

Method __init__

Lib/re/__init__.py:392–408  ·  view source on GitHub ↗
(self, lexicon, flags=0)

Source from the content-addressed store, hash-verified

390
391class Scanner:
392 def __init__(self, lexicon, flags=0):
393 from ._constants import BRANCH, SUBPATTERN
394 if isinstance(flags, RegexFlag):
395 flags = flags.value
396 self.lexicon = lexicon
397 # combine phrases into a compound pattern
398 p = []
399 s = _parser.State()
400 s.flags = flags
401 for phrase, action in lexicon:
402 gid = s.opengroup()
403 p.append(_parser.SubPattern(s, [
404 (SUBPATTERN, (gid, 0, 0, _parser.parse(phrase, flags))),
405 ]))
406 s.closegroup(gid, p[-1])
407 p = _parser.SubPattern(s, [(BRANCH, (None, p))])
408 self.scanner = _compiler.compile(p)
409 def scan(self, string):
410 result = []
411 append = result.append

Callers

nothing calls this directly

Calls 6

opengroupMethod · 0.95
appendMethod · 0.95
closegroupMethod · 0.95
isinstanceFunction · 0.85
parseMethod · 0.45
compileMethod · 0.45

Tested by

no test coverage detected