MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / parse

Function parse

tools/python-3.11.9-amd64/Lib/re/_parser.py:979–1004  ·  view source on GitHub ↗
(str, flags=0, state=None)

Source from the content-addressed store, hash-verified

977 return flags
978
979def parse(str, flags=0, state=None):
980 # parse 're' pattern into list of (opcode, argument) tuples
981
982 source = Tokenizer(str)
983
984 if state is None:
985 state = State()
986 state.flags = flags
987 state.str = str
988
989 p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
990 p.state.flags = fix_flags(str, p.state.flags)
991
992 if source.next is not None:
993 assert source.next == ")"
994 raise source.error("unbalanced parenthesis")
995
996 for g in p.state.grouprefpos:
997 if g >= p.state.groups:
998 msg = "invalid group reference %d" % g
999 raise error(msg, str, p.state.grouprefpos[g])
1000
1001 if flags & SRE_FLAG_DEBUG:
1002 p.dump()
1003
1004 return p
1005
1006def parse_template(source, state):
1007 # parse 're' replacement string into list of literals and

Callers

nothing calls this directly

Calls 7

errorMethod · 0.95
TokenizerClass · 0.85
_parse_subFunction · 0.85
fix_flagsFunction · 0.85
StateClass · 0.70
errorClass · 0.70
dumpMethod · 0.45

Tested by

no test coverage detected