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

Function build_python_parser_and_generator

Tools/peg_generator/pegen/build.py:369–394  ·  view source on GitHub ↗

Generate rules, python parser, tokenizer, parser generator for a given grammar Args: grammar_file (string): Path for the grammar file output_file (string): Path for the output file verbose_tokenizer (bool, optional): Whether to display additional output when ge

(
    grammar_file: str,
    output_file: str,
    verbose_tokenizer: bool = False,
    verbose_parser: bool = False,
    skip_actions: bool = False,
)

Source from the content-addressed store, hash-verified

367
368
369def build_python_parser_and_generator(
370 grammar_file: str,
371 output_file: str,
372 verbose_tokenizer: bool = False,
373 verbose_parser: bool = False,
374 skip_actions: bool = False,
375) -> tuple[Grammar, Parser, Tokenizer, ParserGenerator]:
376 """Generate rules, python parser, tokenizer, parser generator for a given grammar
377
378 Args:
379 grammar_file (string): Path for the grammar file
380 output_file (string): Path for the output file
381 verbose_tokenizer (bool, optional): Whether to display additional output
382 when generating the tokenizer. Defaults to False.
383 verbose_parser (bool, optional): Whether to display additional output
384 when generating the parser. Defaults to False.
385 skip_actions (bool, optional): Whether to pretend no rule has any actions.
386 """
387 grammar, parser, tokenizer = build_parser(grammar_file, verbose_tokenizer, verbose_parser)
388 gen = build_python_generator(
389 grammar,
390 grammar_file,
391 output_file,
392 skip_actions=skip_actions,
393 )
394 return grammar, parser, tokenizer, gen

Callers 1

generate_python_codeFunction · 0.90

Calls 2

build_parserFunction · 0.85
build_python_generatorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…