git.haldean.org cvm / 0f91a94
Add debugging flags, and more granularity in what gets printed. Will Brown 9 years ago
2 changed file(s) with 18 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
1616 write_binary(parse_instructions(source), binout)
1717 else:
1818 tree = parse(preprocess(source))
19 print_tree(tree)
20 if tree:
21 with open(args.output, 'w') as binout:
22 write_binary(link(*translate(tree)), binout)
19 if args.write_ast:
20 print_tree(tree)
21 if not tree:
22 return
23
24 instructions = link(*translate(tree))
25 if args.write_assembly:
26 for c in instructions:
27 print(c)
28
29 with open(args.output, 'w') as binout:
30 write_binary(instructions, binout)
2331
2432 def preprocess(source):
2533 result = ''
99 ap.add_argument(
1010 '-o', '--output', default='out.cvm', metavar='BYTECODE_FILE',
1111 help='output bytecode file')
12 ap.add_argument(
13 '--write-assembly', action='store_true',
14 help='write out generated assembly instructions')
15 ap.add_argument(
16 '--write-ast', action='store_true',
17 help='write out AST')
1218 ap.add_argument('input_file', metavar='INPUT_FILE')
1319
1420 args = ap.parse_args()