equal
deleted
inserted
replaced
4 Common markup elements. |
4 Common markup elements. |
5 *) |
5 *) |
6 |
6 |
7 signature MARKUP = |
7 signature MARKUP = |
8 sig |
8 sig |
|
9 val parse_int: string -> int |
|
10 val print_int: int -> string |
9 type T = string * Properties.T |
11 type T = string * Properties.T |
10 val none: T |
12 val none: T |
11 val is_none: T -> bool |
13 val is_none: T -> bool |
12 val properties: Properties.T -> T -> T |
14 val properties: Properties.T -> T -> T |
13 val nameN: string |
15 val nameN: string |
107 val forkedN: string val forked: T |
109 val forkedN: string val forked: T |
108 val joinedN: string val joined: T |
110 val joinedN: string val joined: T |
109 val failedN: string val failed: T |
111 val failedN: string val failed: T |
110 val finishedN: string val finished: T |
112 val finishedN: string val finished: T |
111 val disposedN: string val disposed: T |
113 val disposedN: string val disposed: T |
112 val assignN: string val assign: T |
114 val versionN: string |
113 val editN: string val edit: string -> string -> T |
115 val execN: string |
|
116 val assignN: string val assign: int -> T |
|
117 val editN: string val edit: int -> int -> T |
114 val pidN: string |
118 val pidN: string |
115 val promptN: string val prompt: T |
119 val promptN: string val prompt: T |
116 val readyN: string val ready: T |
120 val readyN: string val ready: T |
117 val no_output: output * output |
121 val no_output: output * output |
118 val default_output: T -> output * output |
122 val default_output: T -> output * output |
125 structure Markup: MARKUP = |
129 structure Markup: MARKUP = |
126 struct |
130 struct |
127 |
131 |
128 (** markup elements **) |
132 (** markup elements **) |
129 |
133 |
|
134 (* integers *) |
|
135 |
|
136 fun parse_int s = |
|
137 (case Int.fromString s of |
|
138 SOME i => i |
|
139 | NONE => raise Fail ("Bad integer: " ^ quote s)); |
|
140 |
|
141 val print_int = signed_string_of_int; |
|
142 |
|
143 |
130 (* basic markup *) |
144 (* basic markup *) |
131 |
145 |
132 type T = string * Properties.T; |
146 type T = string * Properties.T; |
133 |
147 |
134 val none = ("", []); |
148 val none = ("", []); |
140 fun properties more_props ((elem, props): T) = |
154 fun properties more_props ((elem, props): T) = |
141 (elem, fold_rev Properties.put more_props props); |
155 (elem, fold_rev Properties.put more_props props); |
142 |
156 |
143 fun markup_elem elem = (elem, (elem, []): T); |
157 fun markup_elem elem = (elem, (elem, []): T); |
144 fun markup_string elem prop = (elem, fn s => (elem, [(prop, s)]): T); |
158 fun markup_string elem prop = (elem, fn s => (elem, [(prop, s)]): T); |
145 fun markup_int elem prop = (elem, fn i => (elem, [(prop, Int.toString i)]): T); |
159 fun markup_int elem prop = (elem, fn i => (elem, [(prop, print_int i)]): T); |
146 |
160 |
147 |
161 |
148 (* name *) |
162 (* name *) |
149 |
163 |
150 val nameN = "name"; |
164 val nameN = "name"; |
313 val (disposedN, disposed) = markup_elem "disposed"; |
327 val (disposedN, disposed) = markup_elem "disposed"; |
314 |
328 |
315 |
329 |
316 (* interactive documents *) |
330 (* interactive documents *) |
317 |
331 |
318 val (assignN, assign) = markup_elem "assign"; |
332 val versionN = "version"; |
|
333 val execN = "exec"; |
|
334 val (assignN, assign) = markup_int "assign" versionN; |
319 |
335 |
320 val editN = "edit"; |
336 val editN = "edit"; |
321 fun edit id state_id : T = (editN, [(idN, id), (stateN, state_id)]); |
337 fun edit cmd_id exec_id : T = (editN, [(idN, print_int cmd_id), (execN, print_int exec_id)]); |
322 |
338 |
323 |
339 |
324 (* messages *) |
340 (* messages *) |
325 |
341 |
326 val pidN = "pid"; |
342 val pidN = "pid"; |