diff options
Diffstat (limited to 'driver.fun')
-rw-r--r-- | driver.fun | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -42,7 +42,19 @@ functor Driver(E: EMIT): DRIVER = struct parseFlag C arg tail else case file of - NONE => parseCmdArgs (updateC C s#file (SOME arg) %) tail + NONE => + let + val size = size arg + in + if String.extract (arg, size - 2, NONE) <> ".c" then + die `arg `": expected file with .c suffix" % + else + let + val file = String.substring (arg, 0, size - 2) + in + parseCmdArgs (updateC C s#file (SOME file) %) tail + end + end | SOME _ => die `arg `": file already specified" % fun exec () = @@ -53,7 +65,7 @@ functor Driver(E: EMIT): DRIVER = struct case (#mode config) of Normal => let - val parseCtx = P.createCtx file (#includeDirs config) + val parseCtx = P.createCtx file (#includeDirs config) true fun collect ctx = let @@ -67,9 +79,9 @@ functor Driver(E: EMIT): DRIVER = struct val parseCtx = collect parseCtx val progInfo = P.explode parseCtx - val ilCtx = I.createCtx progInfo + val ilCtx = I.createCtx progInfo (SOME $ file ^ ".i") in - E.emit "/tmp/prog.s" ilCtx + E.emit (file ^ ".s") ilCtx (SOME $ file ^ ".e") end | DebugT => P.P.T.debugPrint file | DebugE => P.P.debugPrint file (#includeDirs config) |