-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpeadae.mc
45 lines (40 loc) · 1.02 KB
/
peadae.mc
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
include "arg.mc"
include "./ast.mc"
include "./error-print.mc"
include "./dae-arg.mc"
include "./parse.mc"
include "./desugar.mc"
include "./pprint.mc"
include "./compile.mc"
lang PEADAE =
DAEAst +
DAEParseAst +
DAEParseDesugar +
DAEParseAnalysis +
DAECompile
end
mexpr
use PEADAE in
switch argParse defaultOptions argConfig
case ParseOK r then
-- Print menu if not exactly one file argument
if neqi (length r.strings) 1 then
print (usage (get argv 0));
exit 1
else
(if r.options.debug then logSetLogLevel logLevel.debug else ());
let res =
let filename = head r.strings in
logMsg logLevel.debug (lam. strJoin " " ["compiling", filename]);
let prog = parseDAEParseExn filename (readFile filename) in
result.bind (daeProgWellFormed prog)
(lam prog.
let t = daeCompile r.options (daeDesugarProg prog) in
printLn (strJoin "\n" ["mexpr", expr2str t]);
result.ok ())
in
consumeWarnErrsExn res
case result then
argPrintError result;
exit 1
end