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,
)
| 367 | |
| 368 | |
| 369 | def 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 |
no test coverage detected
searching dependent graphs…