-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmicroc.fs
More file actions
28 lines (21 loc) · 840 Bytes
/
microc.fs
File metadata and controls
28 lines (21 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
let fromFile = Parse.fromFile
let compileToFile = Comp.compileToFile
let argv = System.Environment.GetCommandLineArgs();;
let args = Array.filter ((<>) "-g") argv
let _ = printfn "Micro-C Stack VM compiler v 1.2.0 of 2021-5-12";;
let _ =
if args.Length > 1 then
let source = args.[1]
let stem =
if source.EndsWith(".c")
then source.Substring(0,source.Length-2)
else source
let target = stem + ".out"
printfn "Compiling %s ......\n" source
try (let instrs = compileToFile (fromFile source) stem;
// printf "StackVM code:\n%A\n" instrs;
printfn "Numeric code saved in file:\n\t%s\nPlease run with VM." target;
)
with Failure msg -> printfn "ERROR: %s" msg
else
printfn "Usage: microc.exe <source file>";