-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.sml
37 lines (32 loc) · 1.04 KB
/
main.sml
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
open Std
val version = "0.1.4"
fun fail s =
let val () = TextIO.output (TextIO.stdErr, "error: " ^ s ^ "\n") in
OS.Process.exit OS.Process.failure
end
structure M = CLI struct
val args = CommandLine.arguments ()
end
fun print_endline s = print $ s ^ "\n"
val () =
case M.v of
M.Help => print M.usage
| M.Version => print_endline $ "Bright ML version " ^ version
| M.Error e => print_endline $ M.show_error e
| M.Normal(s, flag) =>
let val path = Filepath.relative s in
case parse_file path >>= (fn bs =>
let
val (no_std, f) =
case flag of
M.Std f => (false, f)
| M.NoStd f => (true, f)
in
case f of
M.None => elaborate no_std path bs >>= interpret
| M.Parse => Right ()
| M.Typecheck => ignore <$> elaborate no_std path bs
end) of
Right _ => ()
| Left s => fail s
end