-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmicroc.fsx
More file actions
29 lines (22 loc) · 907 Bytes
/
microc.fsx
File metadata and controls
29 lines (22 loc) · 907 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
29
#r "FsLexYacc.Runtime.dll";;
#load "Absyn.fs" "CPar.fs" "CLex.fs" "Parse.fs" "Machine.fs" "Comp.fs" ;;
let fromFile = Parse.fromFile
let compileToFile = Comp.compileToFile
let args = System.Environment.GetCommandLineArgs();;
let _ = printf "Micro-C Stack VM compiler v 1.0.0.1 of 2017-12-2\n";;
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"
printf "Compiling %s to %s\n" source target
try (let instrs = compileToFile (fromFile source) target;
printf "StackVM code:\n%A\n" instrs;
printf "Numeric code in file:\n\t%s\n Please run with VM.\n" target;
)
with Failure msg -> printf "ERROR: %s\n" msg
else
printf "Usage: microc.exe <source file> \n";