implement -E command-line switch

This commit is contained in:
Josh Holtrop 2011-08-30 16:34:51 -04:00
parent 0ddfabc64b
commit 1609cf5911

18
jtlc
View File

@ -35,13 +35,23 @@ def main(argv):
success = translate(args, s, tf)
tf.close()
if success:
suffix = '.c' if args.E else '.o'
m = re.match('(.*)\.jtl', s)
if m is not None:
ofname = m.group(1) + '.o'
ofname = m.group(1) + suffix
else:
ofname = s + '.o'
success = do_compile(args, tfname, ofname)
ofiles.append(ofname)
ofname = s + suffix
if args.E:
f = open(tfname, 'r')
content = f.read()
f.close()
f = open(ofname, 'w')
f.write(content)
f.close()
return 0
else:
success = do_compile(args, tfname, ofname)
ofiles.append(ofname)
os.unlink(tfname)
if success and not args.c: