Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (25 sloc) 774 Bytes
import sys
import mparser
import analyser
import collapser
import generator
def compile(infile, outfile, optimize=False):
generator.OPTIMIZED_MODE = optimize
fset = mparser.parse_program(open(infile).read())
out = generator.generate_program(fset)
open(outfile, 'w').write(out)
if __name__ == '__main__':
args = sys.argv[1:]
if len(args) == 3 and args[0] == '-O':
compile(args[1], args[2], True)
elif len(args) == 2 and args[0] == '-O':
compile(args[1], 'out.txt', True)
elif len(args) == 2:
compile(args[0], args[1], False)
elif len(args) == 1:
compile(args[0], 'out.txt', False)
print 'Usage: compiler [-O] source_file [object_file]'
Something went wrong with that request. Please try again.