MCPcopy Index your code
hub / github.com/python/cpython / generate_parser

Function generate_parser

Tools/peg_generator/pegen/testutil.py:26–35  ·  view source on GitHub ↗
(grammar: Grammar)

Source from the content-addressed store, hash-verified

24
25
26def generate_parser(grammar: Grammar) -> type[Parser]:
27 # Generate a parser.
28 out = io.StringIO()
29 genr = PythonParserGenerator(grammar, out)
30 genr.generate("<string>")
31
32 # Load the generated parser class.
33 ns: dict[str, Any] = {}
34 exec(out.getvalue(), ns)
35 return ns["GeneratedParser"]
36
37
38def run_parser(file: IO[bytes], parser_class: type[Parser], *, verbose: bool = False) -> Any:

Callers 2

test_left_recursiveMethod · 0.90
make_parserFunction · 0.85

Calls 3

generateMethod · 0.95
getvalueMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…