Debian Codegraph @

lib/mllpt-lib/ml-lpt/ml-antlr/examples/c/cmain.sml

raw
1 structure Main =
2 struct
3
4 structure P = Parser(ListLexer)
5
6 fun parse(strm) = let
7 fun inputN n = (case TextIO.inputLine strm
8 of SOME s => s
9 | NONE => "")
10 val lexer = Mlex.makeLexer inputN
11 fun lex() = (case lexer()
12 of Tok.EOF => [Tok.EOF]
13 | t => t :: lex())
14 in
15 #1 (P.parser (lex()))
16 end
17
18 fun errMsg l =
19 TextIO.output(TextIO.stdErr, String.concat l)
20
21 fun main (_, [file]) = (
22 parse (TextIO.openIn file);
23 OS.Process.success)
24 handle ex => (
25 errMsg [
26 "uncaught exception ", General.exnName ex,
27 " [", exnMessage ex, "]\n"
28 ];
29 List.app (fn s => errMsg [" raised at ", s, "\n"]) (SMLofNJ.exnHistory ex);
30 OS.Process.failure)
31
32 end