Generate rules, C parser, tokenizer, parser generator for a given grammar Args: grammar_file (string): Path for the grammar file tokens_file (string): Path for the tokens file output_file (string): Path for the output file compile_extension (bool, optional): Whet
(
grammar_file: str,
tokens_file: str,
output_file: str,
compile_extension: bool = False,
verbose_tokenizer: bool = False,
verbose_parser: bool = False,
verbose_c_extension: bool = False,
keep_asserts_in_extension: bool = True,
skip_actions: bool = False,
)
| 323 | |
| 324 | |
| 325 | def build_c_parser_and_generator( |
| 326 | grammar_file: str, |
| 327 | tokens_file: str, |
| 328 | output_file: str, |
| 329 | compile_extension: bool = False, |
| 330 | verbose_tokenizer: bool = False, |
| 331 | verbose_parser: bool = False, |
| 332 | verbose_c_extension: bool = False, |
| 333 | keep_asserts_in_extension: bool = True, |
| 334 | skip_actions: bool = False, |
| 335 | ) -> tuple[Grammar, Parser, Tokenizer, ParserGenerator]: |
| 336 | """Generate rules, C parser, tokenizer, parser generator for a given grammar |
| 337 | |
| 338 | Args: |
| 339 | grammar_file (string): Path for the grammar file |
| 340 | tokens_file (string): Path for the tokens file |
| 341 | output_file (string): Path for the output file |
| 342 | compile_extension (bool, optional): Whether to compile the C extension. |
| 343 | Defaults to False. |
| 344 | verbose_tokenizer (bool, optional): Whether to display additional output |
| 345 | when generating the tokenizer. Defaults to False. |
| 346 | verbose_parser (bool, optional): Whether to display additional output |
| 347 | when generating the parser. Defaults to False. |
| 348 | verbose_c_extension (bool, optional): Whether to display additional |
| 349 | output when compiling the C extension . Defaults to False. |
| 350 | keep_asserts_in_extension (bool, optional): Whether to keep the assert statements |
| 351 | when compiling the extension module. Defaults to True. |
| 352 | skip_actions (bool, optional): Whether to pretend no rule has any actions. |
| 353 | """ |
| 354 | grammar, parser, tokenizer = build_parser(grammar_file, verbose_tokenizer, verbose_parser) |
| 355 | gen = build_c_generator( |
| 356 | grammar, |
| 357 | grammar_file, |
| 358 | tokens_file, |
| 359 | output_file, |
| 360 | compile_extension, |
| 361 | verbose_c_extension, |
| 362 | keep_asserts_in_extension, |
| 363 | skip_actions=skip_actions, |
| 364 | ) |
| 365 | |
| 366 | return grammar, parser, tokenizer, gen |
| 367 | |
| 368 | |
| 369 | def build_python_parser_and_generator( |
no test coverage detected
searching dependent graphs…