Commit a14a2dd8 authored by di68kap's avatar di68kap
Browse files


parent 12ef3fd3
......@@ -328,6 +328,9 @@ class ts2dataclassCompiler(Compiler):
# def on_qualifier(self, node):
# return node
def on_variable(self, node) -> str:
return node.content
def on_identifier(self, node) -> str:
return node.content
......@@ -447,13 +450,15 @@ def batch_process(file_names: List[str], out_dir: str,
INSPECT_TEMPLATE = """<h2>{testname}</h2>
<code style="background-color: lightgrey;">
<div style="background-color: antiquewhite;">
<code style="white-space: pre-wrap;">{ast_str}
<h3>Program code</h3>
<code style="background-color: yellow;">
<div style="background-color: yellow;">
<code style="white-space: pre-wrap;">{code}
......@@ -468,18 +473,18 @@ def inspect(test_file_path: str):
for parser in test_unit:
for testname, test_code in test_unit[parser].get('match', dict()).items():
ast = grammar(test_code, parser)
ast_str = ast.as_tree()
ast_str = ast.as_tree()
code = compiler(ast)
results.append(INSPECT_TEMPLATE.format(testname=testname, ast_str=ast_str, code=code))
testname=testname, ast_str=ast_str, code=code))
test_file_name = os.path.basename(test_file_path)
results_str = '\n '.join(results)
html = f'''<html>
html = f'''<!DOCTYPE html>\n<html>
<head><meta charset="utf-8"><title>{test_file_name}</title></head>
destdir = os.path.join(os.path.dirname(test_file_path), "REPORT")
if not os.path.exists(destdir): os.mkdir(destdir)
destpath = os.path.join(destdir, test_file_name[:-4] + '.html')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment