src/Pure/ProofGeneral/pgip_markup.ML
author wenzelm
Sun, 22 Jul 2012 12:26:41 +0200
changeset 48423 0ccf143a2a69
parent 38228 ada3ab6b9085
permissions -rw-r--r--
maintain set of source digests, including relevant parts of session entry;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     1
(*  Title:      Pure/ProofGeneral/pgip_markup.ML
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     2
    Author:     David Aspinall
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     3
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     4
PGIP abstraction: document markup for proof scripts (in progress).
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     5
*)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     6
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     7
signature PGIPMARKUP =
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     8
sig
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
     9
  (* Generic markup on sequential, non-overlapping pieces of proof text *)
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    10
  datatype pgipdoc =
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    11
    Openblock     of { metavarid: string option, name: string option,
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    12
                       objtype: PgipTypes.objtype option }
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    13
  | Closeblock    of { }
24192
4eccd4bb8b64 PGIP change: thyname is optional in opentheory, markup even in case of header parse failure
aspinall
parents: 23834
diff changeset
    14
  | Opentheory    of { thyname: string option, parentnames: string list , text: string}
22404
790935f7c1ab Add more attributes to openblock. Change theory item objtype field to proper objtype.
aspinall
parents: 21886
diff changeset
    15
  | Theoryitem    of { name: string option, objtype: PgipTypes.objtype option, text: string }
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    16
  | Closetheory   of { text: string }
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    17
  | Opengoal      of { thmname: string option, text: string }
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    18
  | Proofstep     of { text: string }
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    19
  | Closegoal     of { text: string }
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    20
  | Giveupgoal    of { text: string }
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    21
  | Postponegoal  of { text: string }
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    22
  | Comment       of { text: string }
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    23
  | Doccomment    of { text: string }
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    24
  | Whitespace    of { text: string }
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    25
  | Spuriouscmd   of { text: string }
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    26
  | Badcmd        of { text: string }
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    27
  | Unparseable   of { text: string }
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    28
  | Metainfo      of { name: string option, text: string }
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    29
  (* Last three for PGIP literate markup only: *)
26548
41bbcaf3e481 further cleanup of XML signature;
wenzelm
parents: 24192
diff changeset
    30
  | Litcomment    of { format: string option, content: XML.tree list }
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    31
  | Showcode      of { show: bool }
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    32
  | Setformat     of { format: string }
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    33
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    34
  type pgipdocument = pgipdoc list
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    35
  type pgip_parser  = string -> pgipdocument       (* system must provide a parser P *)
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    36
  val unparse_doc : pgipdocument -> string list    (* s.t. unparse (P x) = x         *)
26548
41bbcaf3e481 further cleanup of XML signature;
wenzelm
parents: 24192
diff changeset
    37
  val output_doc : pgipdocument -> XML.tree list
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    38
  val doc_markup_elements : string list            (* used in pgip_input *)
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    39
  val doc_markup_elements_ignored : string list    (* used in pgip_input *)
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    40
end
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    41
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    42
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    43
structure PgipMarkup : PGIPMARKUP =
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    44
struct
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    45
   open PgipTypes
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    46
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
    47
(* PGIP 3 idea: replace opentheory, opengoal, etc. by just openblock with corresponding objtype? *)
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    48
  datatype pgipdoc =
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    49
    Openblock     of { metavarid: string option, name: string option,
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    50
                       objtype: PgipTypes.objtype option }
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    51
  | Closeblock    of { }
24192
4eccd4bb8b64 PGIP change: thyname is optional in opentheory, markup even in case of header parse failure
aspinall
parents: 23834
diff changeset
    52
  | Opentheory    of { thyname: string option, parentnames: string list, text: string}
22404
790935f7c1ab Add more attributes to openblock. Change theory item objtype field to proper objtype.
aspinall
parents: 21886
diff changeset
    53
  | Theoryitem    of { name: string option, objtype: PgipTypes.objtype option, text: string }
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    54
  | Closetheory   of { text: string }
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    55
  | Opengoal      of { thmname: string option, text: string }
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    56
  | Proofstep     of { text: string }
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    57
  | Closegoal     of { text: string }
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    58
  | Giveupgoal    of { text: string }
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    59
  | Postponegoal  of { text: string }
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    60
  | Comment       of { text: string }
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    61
  | Doccomment    of { text: string }
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    62
  | Whitespace    of { text: string }
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    63
  | Spuriouscmd   of { text: string }
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    64
  | Badcmd        of { text: string }
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    65
  | Unparseable   of { text: string }
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    66
  | Metainfo      of { name: string option, text: string }
26548
41bbcaf3e481 further cleanup of XML signature;
wenzelm
parents: 24192
diff changeset
    67
  | Litcomment    of { format: string option, content: XML.tree list }
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    68
  | Showcode      of { show: bool }
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    69
  | Setformat     of { format: string }
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    70
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    71
  type pgipdocument = pgipdoc list
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    72
  type pgip_parser  = string -> pgipdocument
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    73
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    74
   fun xml_of docelt =
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    75
       case docelt of
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
    76
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    77
           Openblock vs  =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
    78
           XML.Elem(("openblock", opt_attr "name" (#metavarid vs) @
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
    79
                                  opt_attr_map PgipTypes.name_of_objtype "objtype" (#objtype vs) @
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
    80
                                  opt_attr "metavarid" (#metavarid vs)),
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    81
                    [])
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    82
23834
ad6ad61332fa avoid redundant variables in patterns (which made Alice vomit);
wenzelm
parents: 23799
diff changeset
    83
         | Closeblock _ =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
    84
           XML.Elem(("closeblock", []), [])
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    85
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    86
         | Opentheory vs  =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
    87
           XML.Elem(("opentheory",
24192
4eccd4bb8b64 PGIP change: thyname is optional in opentheory, markup even in case of header parse failure
aspinall
parents: 23834
diff changeset
    88
                    opt_attr "thyname" (#thyname vs) @
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    89
                    opt_attr "parentnames"
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    90
                             (case (#parentnames vs)
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    91
                               of [] => NONE
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
    92
                                | ps => SOME (space_implode ";" ps))),
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    93
                    [XML.Text (#text vs)])
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
    94
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    95
         | Theoryitem vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
    96
           XML.Elem(("theoryitem",
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    97
                    opt_attr "name" (#name vs) @
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
    98
                    opt_attr_map PgipTypes.name_of_objtype "objtype" (#objtype vs)),
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
    99
                    [XML.Text (#text vs)])
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   100
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   101
         | Closetheory vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   102
           XML.Elem(("closetheory", []), [XML.Text (#text vs)])
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   103
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   104
         | Opengoal vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   105
           XML.Elem(("opengoal",
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   106
                    opt_attr "thmname" (#thmname vs)),
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   107
                    [XML.Text (#text vs)])
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   108
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   109
         | Proofstep vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   110
           XML.Elem(("proofstep", []), [XML.Text (#text vs)])
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   111
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   112
         | Closegoal vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   113
           XML.Elem(("closegoal", []), [XML.Text (#text vs)])
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   114
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   115
         | Giveupgoal vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   116
           XML.Elem(("giveupgoal", []), [XML.Text (#text vs)])
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   117
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   118
         | Postponegoal vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   119
           XML.Elem(("postponegoal", []), [XML.Text (#text vs)])
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   120
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   121
         | Comment vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   122
           XML.Elem(("comment", []), [XML.Text (#text vs)])
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   123
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   124
         | Whitespace vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   125
           XML.Elem(("whitespace", []), [XML.Text (#text vs)])
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
   126
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   127
         | Doccomment vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   128
           XML.Elem(("doccomment", []), [XML.Text (#text vs)])
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   129
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   130
         | Spuriouscmd vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   131
           XML.Elem(("spuriouscmd", []), [XML.Text (#text vs)])
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   132
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   133
         | Badcmd vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   134
           XML.Elem(("badcmd", []), [XML.Text (#text vs)])
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   135
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   136
         | Unparseable vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   137
           XML.Elem(("unparseable", []), [XML.Text (#text vs)])
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
   138
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   139
         | Metainfo vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   140
           XML.Elem(("metainfo", opt_attr "name" (#name vs)),
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   141
                    [XML.Text (#text vs)])
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   142
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   143
         | Litcomment vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   144
           XML.Elem(("litcomment", opt_attr "format" (#format vs)),
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   145
                   #content vs)
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   146
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   147
         | Showcode vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   148
           XML.Elem(("showcode",
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   149
                    attr "show" (PgipTypes.bool_to_pgstring (#show vs))), [])
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   150
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   151
         | Setformat vs =>
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   152
           XML.Elem(("setformat", attr "format" (#format vs)), [])
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   153
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   154
   val output_doc = map xml_of
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   155
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   156
   fun unparse_elt docelt =
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   157
   case docelt of
23834
ad6ad61332fa avoid redundant variables in patterns (which made Alice vomit);
wenzelm
parents: 23799
diff changeset
   158
       Openblock _ => ""
ad6ad61332fa avoid redundant variables in patterns (which made Alice vomit);
wenzelm
parents: 23799
diff changeset
   159
     | Closeblock _ => ""
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   160
     | Opentheory vs => #text vs
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   161
     | Theoryitem vs => #text vs
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   162
     | Closetheory vs => #text vs
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   163
     | Opengoal vs => #text vs
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   164
     | Proofstep vs => #text vs
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   165
     | Closegoal vs => #text vs
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   166
     | Giveupgoal vs => #text vs
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   167
     | Postponegoal vs => #text vs
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   168
     | Comment vs => #text vs
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   169
     | Doccomment vs => #text vs
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   170
     | Whitespace vs => #text vs
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   171
     | Spuriouscmd vs => #text vs
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   172
     | Badcmd vs => #text vs
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
   173
     | Unparseable vs => #text vs
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   174
     | Metainfo vs => #text vs
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   175
     | _ => ""
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   176
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   177
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   178
   val unparse_doc = map unparse_elt
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   179
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   180
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   181
   (* Names of all PGIP document markup elements *)
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   182
   val doc_markup_elements =
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   183
       ["openblock",
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   184
        "closeblock",
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   185
        "opentheory",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   186
        "theoryitem",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   187
        "closetheory",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   188
        "opengoal",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   189
        "proofstep",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   190
        "closegoal",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   191
        "giveupgoal",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   192
        "postponegoal",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   193
        "comment",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   194
        "doccomment",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   195
        "whitespace",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   196
        "spuriouscmd",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   197
        "badcmd",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   198
        (* the prover shouldn't really receive the next ones,
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   199
           but we include them here so that they are harmlessly
21886
f1790ca921e1 Missing elements from doc_markup_elements
aspinall
parents: 21867
diff changeset
   200
           ignored. *)
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   201
        "unparseable",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   202
        "metainfo",
21886
f1790ca921e1 Missing elements from doc_markup_elements
aspinall
parents: 21867
diff changeset
   203
        (* Broker document format *)
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   204
        "litcomment",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   205
        "showcode",
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   206
        "setformat"]
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   207
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   208
   (* non-document/empty text, must be ignored *)
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   209
   val doc_markup_elements_ignored =
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21637
diff changeset
   210
       [ "metainfo", "openblock", "closeblock",
23799
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   211
         "litcomment", "showcode", "setformat" ]
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   212
20f58293fc5e tuned spacing;
wenzelm
parents: 22404
diff changeset
   213
end;