Mercurial > lcfOS
view python/zcc.py @ 210:67b0feafe5ae
Added missing file
author | Windel Bouwman |
---|---|
date | Sat, 29 Jun 2013 10:09:50 +0200 |
parents | 8b2f20aae086 |
children | 003c8a976fff |
line wrap: on
line source
#!/usr/bin/python import sys, os, argparse import c3, ppci, codegen import arm_cm3 import codegenarm import outstream # Parse arguments: parser = argparse.ArgumentParser(description='lcfos Compiler') parser.add_argument('source', type=argparse.FileType('r'), help='the source file to build') parser.add_argument('-d', '--dumpir', action='store_true', help="Dump IR-code") parser.add_argument('-o', '--output', help='Output file', metavar='filename') def main(args): # Front end: src = args.source.read() args.source.close() diag = ppci.DiagnosticsManager() c3b = c3.Builder(diag) ircode = c3b.build(src) if not ircode: diag.printErrors(src) sys.exit(1) if args.dumpir: ircode.dump() # Code generation: #cg = codegen.CodeGenerator(arm_cm3.armtarget) outs = outstream.TextOutputStream() cg = codegenarm.ArmCodeGenerator(outs) obj = cg.generate(ircode) if args.dumpir: outs.dump() if args.output: output_filename = args.output else: output_filename = 'lc.output' # TODO: store data if __name__ == '__main__': args = parser.parse_args() print(args, type(args)) main(args)