Mercurial > lcfOS
view python/zcc.py @ 204:de3a68f677a5
Added long comment to c3 parser
author | Windel Bouwman |
---|---|
date | Fri, 21 Jun 2013 15:01:08 +0200 |
parents | 1544e7a4aa98 |
children | d77cb5962cc5 |
line wrap: on
line source
#!/usr/bin/python import sys, os, argparse import c3, ppci parser = argparse.ArgumentParser(description='lcfos Compiler') parser.add_argument('source', type=argparse.FileType('r'), help='the source file to build') args = parser.parse_args() # Building: src = args.source.read() diag = ppci.DiagnosticsManager() c3b = c3.Builder(diag) ircode = c3b.build(src) if not ircode: diag.printErrors(src) sys.exit(1) # optionally run passes here: # TODO print('stage 3: Code generation') asmWriter = core.AsmWriter() asmWriter.printModule(module) # Generate code: bitcodeWriter = core.BitcodeWriter() with open(args.source + '.bc', 'wb') as f: bitcodeWriter.WriteModuleToFile(module, f)