src/Pure/ProofGeneral/pgip_input.ML
author aspinall
Mon, 04 Dec 2006 20:40:11 +0100
changeset 21637 a7b156c404e2
child 21649 40e6fdd26f82
permissions -rw-r--r--
Revamped Proof General interface.
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_input.ML
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     2
    ID:         $Id$
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     3
    Author:     David Aspinall
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     4
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     5
PGIP abstraction: input commands
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     6
*)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     7
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     8
signature PGIPINPUT =
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     9
sig
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    10
    (* These are the PGIP commands to which we respond. *) 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    11
    datatype pgipinput = 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    12
       (* protocol/prover config *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    13
	 Askpgip 	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    14
       | Askpgml 	of { } 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    15
       | Askconfig	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    16
       | Askprefs	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    17
       | Setpref 	of { name:string, prefcategory:string option, value:string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    18
       | Getpref 	of { name:string, prefcategory:string option }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    19
       (* prover control *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    20
       | Proverinit 	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    21
       | Proverexit 	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    22
       | Startquiet 	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    23
       | Stopquiet	of { } 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    24
       | Pgmlsymbolson  of { } 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    25
       | Pgmlsymbolsoff of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    26
       (* improper proof commands: control proof state *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    27
       | Dostep		of { text: string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    28
       | Undostep	of { times: int }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    29
       | Redostep	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    30
       | Abortgoal	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    31
       | Forget		of { thyname: string option, name: string option, 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    32
			     objtype: string option }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    33
       | Restoregoal    of { thmname : string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    34
       (* context inspection commands *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    35
       | Askids		of { thyname:string option, objtype:string option }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    36
       | Showid		of { thyname:string option, objtype:string, name:string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    37
       | Askguise	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    38
       | Parsescript	of { text: string, location: PgipTypes.location,
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    39
			     systemdata: string option } 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    40
       | Showproofstate of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    41
       | Showctxt	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    42
       | Searchtheorems of { arg: string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    43
       | Setlinewidth   of { width: int }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    44
       | Viewdoc	of { arg: string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    45
       (* improper theory-level commands *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    46
       | Doitem		of { text: string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    47
       | Undoitem	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    48
       | Redoitem	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    49
       | Aborttheory	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    50
       | Retracttheory  of { thyname: string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    51
       | Loadfile 	of { url: PgipTypes.pgipurl }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    52
       | Openfile 	of { url: PgipTypes.pgipurl }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    53
       | Closefile	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    54
       | Abortfile	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    55
       | Retractfile    of { url: PgipTypes.pgipurl }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    56
       | Changecwd 	of { url: PgipTypes.pgipurl }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    57
       | Systemcmd 	of { arg: string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    58
       (* unofficial escape command for debugging *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    59
       | Quitpgip	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    60
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    61
    val input           : XML.element -> pgipinput option        (* raises PGIP *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    62
end
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    63
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    64
structure PgipInput : PGIPINPUT = 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    65
struct
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    66
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    67
open PgipTypes
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    68
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    69
(*** PGIP input ***)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    70
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    71
datatype pgipinput = 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    72
	 (* protocol/prover config *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    73
	 Askpgip 	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    74
       | Askpgml 	of { } 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    75
       | Askconfig	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    76
       | Askprefs	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    77
       | Setpref 	of { name:string, prefcategory:string option, value:string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    78
       | Getpref 	of { name:string, prefcategory:string option }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    79
       (* prover control *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    80
       | Proverinit 	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    81
       | Proverexit 	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    82
       | Startquiet 	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    83
       | Stopquiet	of { } 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    84
       | Pgmlsymbolson  of { } 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    85
       | Pgmlsymbolsoff of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    86
       (* improper proof commands: control proof state *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    87
       | Dostep		of { text: string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    88
       | Undostep	of { times: int }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    89
       | Redostep	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    90
       | Abortgoal	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    91
       | Forget		of { thyname: string option, name: string option, 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    92
			     objtype: string option }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    93
       | Restoregoal    of { thmname : string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    94
       (* context inspection commands *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    95
       | Askids		of { thyname:string option, objtype:string option }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    96
       | Showid		of { thyname:string option, objtype:string, name:string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    97
       | Askguise	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    98
       | Parsescript	of { text: string, location: location,
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    99
			     systemdata: string option } 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   100
       | Showproofstate of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   101
       | Showctxt	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   102
       | Searchtheorems of { arg: string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   103
       | Setlinewidth   of { width: int }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   104
       | Viewdoc	of { arg: string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   105
       (* improper theory-level commands *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   106
       | Doitem		of { text: string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   107
       | Undoitem	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   108
       | Redoitem	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   109
       | Aborttheory	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   110
       | Retracttheory  of { thyname: string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   111
       | Loadfile 	of { url: pgipurl }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   112
       | Openfile 	of { url: pgipurl }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   113
       | Closefile	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   114
       | Abortfile	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   115
       | Retractfile    of { url: pgipurl }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   116
       | Changecwd 	of { url: pgipurl }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   117
       | Systemcmd 	of { arg: string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   118
       (* unofficial escape command for debugging *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   119
       | Quitpgip	of { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   120
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   121
(* Extracting content from input XML elements to make a PGIPinput *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   122
local
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   123
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   124
    val thyname_attro = get_attr_opt "thyname"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   125
    val thyname_attr = get_attr "thyname"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   126
    val objtype_attro = get_attr_opt "objtype"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   127
    val objtype_attr = get_attr "objtype"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   128
    val name_attr = get_attr "name"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   129
    val name_attro = get_attr_opt "name"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   130
    val thmname_attr = get_attr "thmname"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   131
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   132
    val times_attr = read_pgipnat o (get_attr_dflt "times" "1")
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   133
    val prefcat_attr = get_attr_opt "prefcategory"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   134
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   135
    fun xmltext ((XML.Text text)::ts) = text ^ (xmltext ts)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   136
      | xmltext [] = ""
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   137
      | xmltext _ = raise PGIP "Expected text (PCDATA/CDATA)"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   138
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   139
    exception Unknown
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   140
    exception NoAction
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   141
in
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   142
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   143
(* Return a valid PGIP input command.
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   144
   Raise PGIP exception for invalid data.
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   145
   Return NONE for unknown/unhandled commands. 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   146
*)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   147
fun input (elem, attrs, data) =
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   148
SOME 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   149
 (case elem of 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   150
     "askpgip"        => Askpgip { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   151
   | "askpgml"        => Askpgml { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   152
   | "askconfig"      => Askconfig { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   153
   (* proverconfig *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   154
   | "askprefs"       => Askprefs { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   155
   | "getpref"        => Getpref { name = name_attr attrs, 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   156
				   prefcategory = prefcat_attr attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   157
   | "setpref"        => Setpref { name = name_attr attrs, 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   158
				   prefcategory = prefcat_attr attrs,
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   159
				   value = xmltext data }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   160
   (* provercontrol *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   161
   | "proverinit"     => Proverinit { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   162
   | "proverexit"     => Proverexit { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   163
   | "startquiet"     => Startquiet { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   164
   | "stopquiet"      => Stopquiet { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   165
   | "pgmlsymbolson"  => Pgmlsymbolson { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   166
   (* improperproofcmd: improper commands not in script *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   167
   | "dostep"         => Dostep    { text = xmltext data }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   168
   | "undostep"       => Undostep  { times = times_attr attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   169
   | "redostep"       => Redostep  { } 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   170
   | "abortgoal"      => Abortgoal { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   171
   | "forget"         => Forget { thyname = thyname_attro attrs, 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   172
				  name = name_attro attrs,
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   173
				  objtype = objtype_attro attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   174
   | "restoregoal"    => Restoregoal { thmname = thmname_attr attrs}
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   175
   (* proofctxt: improper commands *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   176
   | "askids"         => Askids { thyname = thyname_attro attrs, 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   177
				  objtype = objtype_attro attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   178
   | "showid"         => Showid { thyname = thyname_attro attrs,
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   179
				  objtype = objtype_attr attrs,
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   180
				  name = name_attr attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   181
   | "askguise"       => Askguise { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   182
   | "parsescript"    => Parsescript { text = (xmltext data),
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   183
				       systemdata = get_attr_opt "systemdata" attrs,
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   184
				       location = location_of_attrs attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   185
   | "showproofstate" => Showproofstate { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   186
   | "showctxt"       => Showctxt { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   187
   | "searchtheorems" => Searchtheorems { arg = xmltext data }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   188
   | "setlinewidth"   => Setlinewidth   { width = read_pgipnat (xmltext data) }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   189
   | "viewdoc"        => Viewdoc { arg = xmltext data }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   190
   (* improperfilecmd: theory-level commands not in script *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   191
   | "doitem"         => Doitem  { text = xmltext data }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   192
   | "undoitem"       => Undoitem { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   193
   | "redoitem"       => Redoitem { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   194
   | "aborttheory"    => Aborttheory { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   195
   | "retracttheory"  => Retracttheory { thyname = thyname_attr attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   196
   | "loadfile"       => Loadfile { url = pgipurl_of_attrs attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   197
   | "openfile"       => Openfile { url = pgipurl_of_attrs attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   198
   | "closefile"      => Closefile { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   199
   | "abortfile"      => Abortfile { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   200
   | "retractfile"    => Retractfile { url = pgipurl_of_attrs attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   201
   | "changecwd"      => Changecwd { url = pgipurl_of_attrs attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   202
   | "systemcmd"      => Systemcmd { arg = xmltext data }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   203
   (* unofficial command for debugging *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   204
   | "quitpgip"	=> Quitpgip { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   205
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   206
   (* We allow sending proper document markup too; we map it back to dostep   *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   207
   (* and strip out metainfo elements. Markup correctness isn't checked: this *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   208
   (* is a compatibility measure to make it easy for interfaces.              *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   209
   | "metainfo"	      => raise NoAction
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   210
   | x => if (x mem PgipMarkup.markup_elements)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   211
	     then Dostep { text = xmltext data } (* could use Doitem too *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   212
	  else raise Unknown) 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   213
    handle Unknown => NONE | NoAction => NONE
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   214
end
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   215
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   216
end