forked from gian/SML-JSON
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjson-test.sml
57 lines (48 loc) · 1.76 KB
/
json-test.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
(*******************************************************************************
* Standard ML JSON parser
* Copyright (C) 2010 Gian Perrone
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************)
structure JSONTrace =
struct
type json_data = unit
fun json_object l = print "json_object\n"
fun json_pair (k,v) = print "json_pair\n"
fun json_array l = print "json_array\n"
fun json_value x = print "json_value\n"
fun json_string s = print "json_string\n"
fun json_int _ = print "json_int\n"
fun json_real _ = print "json_real\n"
fun json_bool _ = print "json_bool\n"
fun json_null () = print "json_null\n"
fun error_handle (msg,pos,data) =
raise Fail ("Error: " ^ msg ^ " near " ^ Int.toString pos ^ " data: " ^
data)
end
structure T = JSONParser (JSONTrace);
fun main () =
let
val k = CommandLine.arguments ()
val _ = if length k = 0 then
raise Fail "No filename supplied"
else ()
val fp = TextIO.openIn (hd k)
val fc = TextIO.inputAll fp
val _ = TextIO.closeIn fp
val _ = T.parse fc
in
()
end
val _ = main ()