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

Function parse

Lib/re/_parser.py:963–988  ·  view source on GitHub ↗
(str, flags=0, state=None)

Source from the content-addressed store, hash-verified

961 return flags
962
963def parse(str, flags=0, state=None):
964 # parse 're' pattern into list of (opcode, argument) tuples
965
966 source = Tokenizer(str)
967
968 if state is None:
969 state = State()
970 state.flags = flags
971 state.str = str
972
973 p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
974 p.state.flags = fix_flags(str, p.state.flags)
975
976 if source.next is not None:
977 assert source.next == ")"
978 raise source.error("unbalanced parenthesis")
979
980 for g in p.state.grouprefpos:
981 if g >= p.state.groups:
982 msg = "invalid group reference %d" % g
983 raise error(msg, str, p.state.grouprefpos[g])
984
985 if flags & SRE_FLAG_DEBUG:
986 p.dump()
987
988 return p
989
990def parse_template(source, pattern):
991 # parse 're' replacement string into list of literals and

Calls 7

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

Tested by 5

test_formatter_parserMethod · 0.40
test_parse_memlimitMethod · 0.40