def recompile_grammar(grammar_src, force): grammar_tests_dir = os.path.join(scriptpath, 'test_grammar') testing.create_test_templates(grammar_src, grammar_tests_dir) # recompiles Grammar only if it has changed if not dsl.recompile_grammar(grammar_src, force=force, notify=lambda: print('recompiling ' + grammar_src)): print('\nErrors while recompiling "%s":' % grammar_src + '\n--------------------------------------\n\n') with open('yaml_ebnf_ERRORS.txt') as f: print(f.read()) sys.exit(1)
def recompile_grammar(grammar_src, force): grammar_tests_dir = os.path.join(scriptpath, 'test_grammar') create_test_templates(grammar_src, grammar_tests_dir) # recompiles Grammar only if it has changed name = os.path.splitext(os.path.basename(grammar_src))[0] if not dsl.recompile_grammar( grammar_src, force=force, notify=lambda: print('recompiling ' + grammar_src)): print('\nErrors while recompiling "{}":'.format(grammar_src) + '\n--------------------------------------\n\n') with open('{}_ebnf_ERRORS.txt'.format(name)) as f: print(f.read()) sys.exit(1)
def recompile_grammar(grammar_src, force): grammar_tests_dir = os.path.join(scriptpath, TEST_DIRNAME) testing.create_test_templates(grammar_src, grammar_tests_dir) # recompiles Grammar only if it has changed if not dsl.recompile_grammar( grammar_src, force=force, notify=lambda: print('recompiling ' + grammar_src)): print('\nErrors while recompiling "%s":' % grammar_src + '\n--------------------------------------\n\n') with open('ts2dataclass_ebnf_ERRORS.txt', encoding='utf-8') as f: print(f.read()) sys.exit(1) dsl.restore_server_script(grammar_src)
def recompile_grammar(grammar_src, force): grammar_tests_dir = os.path.join(scriptpath, 'test_grammar') if not os.path.exists(grammar_tests_dir) \ or not any(os.path.isfile(os.path.join(grammar_tests_dir, entry)) for entry in os.listdir(grammar_tests_dir)): print('No grammar-tests found, generating test templates.') create_test_templates(grammar_src, grammar_tests_dir) DHParser.log.start_logging(LOGGING) # recompiles Grammar only if it has changed name = os.path.splitext(os.path.basename(grammar_src))[0] if not dsl.recompile_grammar(grammar_src, force=force): print('\nErrors while recompiling "{}":'.format(grammar_src) + '\n--------------------------------------\n\n') with open('{}_ebnf_ERRORS.txt'.format(name)) as f: print(f.read()) sys.exit(1)
def recompile_grammar(grammar_src, force): grammar_tests_dir = os.path.join(scriptpath, 'test_grammar') testing.create_test_templates(grammar_src, grammar_tests_dir) DHParser.log.start_logging('LOGS') # recompiles Grammar only if it has changed saved_syntax_variant = get_config_value('syntax_variant') set_config_value('syntax_variant', 'heuristic') if not dsl.recompile_grammar( grammar_src, force=force, notify=lambda: print('recompiling ' + grammar_src)): print('\nErrors while recompiling "%s":' % grammar_src + '\n--------------------------------------\n\n') if is_filename(grammar_src): err_name = grammar_src.replace('.', '_') + '_ERRORS.txt' else: err_name = 'EBNF_ebnf_ERRORS.txt' with open(err_name, encoding='utf-8') as f: print(f.read()) sys.exit(1) set_config_value('syntax_variant', saved_syntax_variant)