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) success = translate(args, s, tf)
tf.close() tf.close()
if success: if success:
suffix = '.c' if args.E else '.o'
m = re.match('(.*)\.jtl', s) m = re.match('(.*)\.jtl', s)
if m is not None: if m is not None:
ofname = m.group(1) + '.o' ofname = m.group(1) + suffix
else: else:
ofname = s + '.o' ofname = s + suffix
success = do_compile(args, tfname, ofname) if args.E:
ofiles.append(ofname) 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) os.unlink(tfname)
if success and not args.c: if success and not args.c: