59714
|
1 |
(* Title: Pure/PIDE/protocol_message.ML
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Auxiliary operations on protocol messages.
|
|
5 |
*)
|
|
6 |
|
|
7 |
signature PROTOCOL_MESSAGE =
|
|
8 |
sig
|
70907
|
9 |
val inline: string -> Properties.T -> unit
|
59714
|
10 |
val command_positions: string -> XML.body -> XML.body
|
|
11 |
val command_positions_yxml: string -> string -> string
|
|
12 |
end;
|
|
13 |
|
|
14 |
structure Protocol_Message: PROTOCOL_MESSAGE =
|
|
15 |
struct
|
|
16 |
|
70907
|
17 |
fun inline a args =
|
|
18 |
writeln ("\f" ^ a ^ " = " ^ YXML.string_of_body (XML.Encode.properties args));
|
|
19 |
|
|
20 |
|
59714
|
21 |
fun command_positions id =
|
|
22 |
let
|
|
23 |
fun attribute (a, b) =
|
|
24 |
if a = Markup.idN andalso b = Markup.commandN then (a, id) else (a, b);
|
|
25 |
fun tree (XML.Elem ((a, atts), ts)) = XML.Elem ((a, map attribute atts), map tree ts)
|
|
26 |
| tree text = text;
|
|
27 |
in map tree end;
|
|
28 |
|
|
29 |
fun command_positions_yxml id =
|
|
30 |
YXML.string_of_body o command_positions id o YXML.parse_body;
|
|
31 |
|
|
32 |
end;
|