def main(argv=None): if argv is None: argv = sys.argv # parse command line options try: try: opts, args = getopt.getopt(argv[1:], "h", ["help"]) except getopt.error, msg: raise Usage(msg) for o, a in opts: if o in ("-h", "--help"): print __doc__ return 0 if (len(args) != 1): raise Usage("A single file name argument is required") fullfilename = args[0] if (fullfilename.endswith('.decaf')): (filename, s, e) = fullfilename.rpartition('.') else: filename = fullfilename infile = filename + ".decaf" ast.initialize_ast() if decafparser.from_file(infile): if (ast.typecheck()): machineCode = codegen.main() mipsCode = cfg.main(machineCode) ami_file = open(filename + ".asm", "w") ami_file.write(mipsCode) ami_file.close() else: print "Failure: there were errors."
def main(argv=None): if argv is None: argv = sys.argv # parse command line options try: try: opts, args = getopt.getopt(argv[1:], "h", ["help"]) except getopt.error, msg: raise Usage(msg) for o, a in opts: if o in ("-h", "--help"): print __doc__ return 0 if (len(args) != 1): raise Usage("A single file name argument is required") fullfilename = args[0] if (fullfilename.endswith('.decaf')): (filename, s, e) = fullfilename.rpartition('.') else: filename = fullfilename infile = filename + ".decaf" ast.initialize_ast() if decafparser.from_file(infile): if (ast.typecheck()): #ast.print_ast() outfile = filename + ".ami" absmc.print_code(outfile, ast.classtable) else: print "Failure: there were errors."