-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sml
35 lines (33 loc) · 1.06 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
structure Main = struct
fun main (_, arguments) =
let
val fileName = case arguments of [] => NONE | a::_ => SOME a
val ins = case fileName of
NONE => TextIO.stdIn
| SOME name => TextIO.openIn name
fun release () =
if Option.isSome fileName then TextIO.closeIn ins else ()
in
let
val sourcemap = case fileName of
NONE => AntlrStreamPos.mkSourcemap ()
| SOME n => AntlrStreamPos.mkSourcemap' n
val (_, doc) =
UXML.parse TextIO.StreamIO.input1 (TextIO.getInstream ins)
fun println s = print (s ^ "\n")
in
println (UXML.showDocument doc);
release ();
OS.Process.success
end
handle e => (release (); raise e)
end
end
fun main () =
let
val name = CommandLine.name ()
val arguments = CommandLine.arguments ()
in
OS.Process.exit (Main.main (name, arguments))
end
val _ = main ()