-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjson_parser.mli
73 lines (63 loc) · 1.56 KB
/
json_parser.mli
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
open Helper
open State
open Yojson.Basic
(*A pair of log data structure*)
type pairlog' = {first : log'; second : log'}
(*A command with attached id*)
type sentcommand = {id : int; command : command}
(**
* Parses a log
*
* requires: j is an [`Assoc] with log mapping
* returns: parsed log
* raises: Failure if precond broken
*)
val parselog : json -> log'
(**
* Sends a log to a json
*
* returns: an [`Assoc] with log mapping
*)
val tojsonlog : log' -> json
(**
* Parses a pair of logs
*
* requires: an [`Assoc] with pairlog' mapping
* returns: the parsed pairlog'
* raises: Failure if precond broken
*)
val parsepairlog : json -> pairlog'
(**
* Sends a pairlog to a json
*
* returns: an [`Assoc] with pairlog' mapping
*)
val tojsonpairlog : pairlog' -> json
(**
* Parses a command. Format is [order; extrastuff if applicable]
*
* requires: j is a [`List l] where l satsifies the above format
* returns: The corresponding command
* raises: [Failure "json is not a command"] if precondition not met
*)
val parsecommand : json -> command
(**
* Sends a command to a json. Format is [order; extrastuff if applicable]
*
* returns: a [`List l] where l follows the above format
*)
val tojsoncommand : command -> json
(**
* Parses a sentcommand
*
* requires: an [`Assoc] with sentcommand mapping
* returns: the parsed sentcommand
* raises: Failure if precond broken
*)
val parsesentcommand : json -> sentcommand
(**
* Sends a sentcommand to a json
*
* returns: an [`Assoc] with sentcommand mapping
*)
val tojsonsentcommand : sentcommand -> json