(
grammar: Grammar,
grammar_file: str,
tokens_file: str,
output_file: str,
compile_extension: bool = False,
verbose_c_extension: bool = False,
keep_asserts_in_extension: bool = True,
skip_actions: bool = False,
)
| 282 | |
| 283 | |
| 284 | def build_c_generator( |
| 285 | grammar: Grammar, |
| 286 | grammar_file: str, |
| 287 | tokens_file: str, |
| 288 | output_file: str, |
| 289 | compile_extension: bool = False, |
| 290 | verbose_c_extension: bool = False, |
| 291 | keep_asserts_in_extension: bool = True, |
| 292 | skip_actions: bool = False, |
| 293 | ) -> ParserGenerator: |
| 294 | with open(tokens_file) as tok_file: |
| 295 | all_tokens, exact_tok, non_exact_tok = generate_token_definitions(tok_file) |
| 296 | with open(output_file, "w") as file: |
| 297 | gen: ParserGenerator = CParserGenerator( |
| 298 | grammar, all_tokens, exact_tok, non_exact_tok, file, skip_actions=skip_actions |
| 299 | ) |
| 300 | gen.generate(grammar_file) |
| 301 | |
| 302 | if compile_extension: |
| 303 | with tempfile.TemporaryDirectory() as build_dir: |
| 304 | compile_c_extension( |
| 305 | output_file, |
| 306 | build_dir=build_dir, |
| 307 | verbose=verbose_c_extension, |
| 308 | keep_asserts=keep_asserts_in_extension, |
| 309 | ) |
| 310 | return gen |
| 311 | |
| 312 | |
| 313 | def build_python_generator( |
no test coverage detected
searching dependent graphs…