-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathh2py
More file actions
executable file
·33 lines (23 loc) · 833 Bytes
/
h2py
File metadata and controls
executable file
·33 lines (23 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
from harmony_model_checker.harmony.DumpASTVisitor import DumpASTVisitor
from harmony_model_checker.h2py.h2py import h2py
from harmony_model_checker.compile import parse
import ast as past
import argparse
parser = argparse.ArgumentParser(description='Harmony to Python')
parser.add_argument('filename')
parser.add_argument('--verbose', action='store_true')
if __name__ == '__main__':
args = parser.parse_args()
harmony_ast = parse(args.filename)
if args.verbose:
print('Dumped Harmony AST:')
dump = DumpASTVisitor(indent_unit=2)
print(dump(harmony_ast))
print()
python_ast = h2py(harmony_ast)
if args.verbose:
print('Dumped Python AST:')
print(past.dump(python_ast, indent=2))
print()
print(past.unparse(python_ast))