src/Pure/ProofGeneral/pgip_input.ML
author wenzelm
Wed, 27 Aug 2008 12:00:28 +0200
changeset 28020 1ff5167592ba
parent 26548 41bbcaf3e481
child 29606 fedb8be05f24
permissions -rw-r--r--
get rid of tabs;
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
21940
fbd068dd4d29 minor tuning;
wenzelm
parents: 21867
diff changeset
     5
PGIP abstraction: input commands.
21637
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 = 
21649
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    12
    (* protocol/prover config *)
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    13
      Askpgip        of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    14
    | Askpgml        of { } 
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    15
    | Askconfig      of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    16
    | Askprefs       of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    17
    | Setpref        of { name:string, prefcategory:string option, value:string }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    18
    | Getpref        of { name:string, prefcategory:string option }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    19
    (* prover control *)
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    20
    | Proverinit     of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    21
    | Proverexit     of { }
22406
a591df440b5b Add setproverflag, to replace other flag controls
aspinall
parents: 22161
diff changeset
    22
    | Setproverflag  of { flagname:string, value: bool }
21649
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    23
    (* improper proof commands: control proof state *)
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    24
    | Dostep         of { text: string }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    25
    | Undostep       of { times: int }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    26
    | Redostep       of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    27
    | Abortgoal      of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    28
    | Forget         of { thyname: string option, name: string option, 
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
    29
                          objtype: PgipTypes.objtype option }
21649
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    30
    | Restoregoal    of { thmname : string }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    31
    (* context inspection commands *)
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
    32
    | Askids         of { url: PgipTypes.pgipurl option,
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    33
                          thyname: PgipTypes.objname option,
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    34
                          objtype: PgipTypes.objtype option }
22161
b2117f4f2d39 Add askrefs, setrefs, error_with_pos
aspinall
parents: 22083
diff changeset
    35
    | Askrefs        of { url: PgipTypes.pgipurl option,
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    36
                          thyname: PgipTypes.objname option,
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    37
                          objtype: PgipTypes.objtype option,
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    38
                          name: PgipTypes.objname option }
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
    39
    | Showid         of { thyname: PgipTypes.objname option, 
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    40
                          objtype: PgipTypes.objtype, 
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    41
                          name: PgipTypes.objname }
21649
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    42
    | Askguise       of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    43
    | Parsescript    of { text: string, location: PgipTypes.location,
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    44
                          systemdata: string option } 
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    45
    | Showproofstate of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    46
    | Showctxt       of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    47
    | Searchtheorems of { arg: string }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    48
    | Setlinewidth   of { width: int }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    49
    | Viewdoc        of { arg: string }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    50
    (* improper theory-level commands *)
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    51
    | Doitem         of { text: string }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    52
    | Undoitem       of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    53
    | Redoitem       of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    54
    | Aborttheory    of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    55
    | Retracttheory  of { thyname: string }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    56
    | Loadfile       of { url: PgipTypes.pgipurl }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    57
    | Openfile       of { url: PgipTypes.pgipurl }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    58
    | Closefile      of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    59
    | Abortfile      of { }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    60
    | Retractfile    of { url: PgipTypes.pgipurl }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    61
    | Changecwd      of { url: PgipTypes.pgipurl }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    62
    | Systemcmd      of { arg: string }
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    63
    (* unofficial escape command for debugging *)
40e6fdd26f82 Support PGIP communication for preferences in Emacs mode.
aspinall
parents: 21637
diff changeset
    64
    | Quitpgip       of { }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    65
26548
41bbcaf3e481 further cleanup of XML signature;
wenzelm
parents: 23436
diff changeset
    66
    val input: string * XML.attributes * XML.tree list -> pgipinput option  (* raises PGIP *)
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    67
end
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    68
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    69
structure PgipInput : PGIPINPUT = 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    70
struct
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    71
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    72
open PgipTypes
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    73
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    74
(*** PGIP input ***)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    75
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    76
datatype pgipinput = 
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    77
         (* protocol/prover config *)
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    78
         Askpgip        of { }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    79
       | Askpgml        of { } 
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    80
       | Askconfig      of { }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    81
       | Askprefs       of { }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    82
       | Setpref        of { name:string, prefcategory:string option, value:string }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    83
       | Getpref        of { name:string, prefcategory:string option }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    84
       (* prover control *)
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    85
       | Proverinit     of { }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    86
       | Proverexit     of { }
22406
a591df440b5b Add setproverflag, to replace other flag controls
aspinall
parents: 22161
diff changeset
    87
       | Setproverflag  of { flagname:string, value: bool }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    88
       (* improper proof commands: control proof state *)
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    89
       | Dostep         of { text: string }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    90
       | Undostep       of { times: int }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    91
       | Redostep       of { }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    92
       | Abortgoal      of { }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    93
       | Forget         of { thyname: string option, name: string option, 
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    94
                             objtype: PgipTypes.objtype option }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    95
       | Restoregoal    of { thmname : string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    96
       (* context inspection commands *)
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
    97
       | Askids         of { url: PgipTypes.pgipurl option,
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    98
                             thyname: PgipTypes.objname option,
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
    99
                             objtype: PgipTypes.objtype option }
22161
b2117f4f2d39 Add askrefs, setrefs, error_with_pos
aspinall
parents: 22083
diff changeset
   100
       | Askrefs        of { url: PgipTypes.pgipurl option,
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   101
                             thyname: PgipTypes.objname option,
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   102
                             objtype: PgipTypes.objtype option,
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   103
                             name: PgipTypes.objname option }
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
   104
       | Showid         of { thyname: PgipTypes.objname option, 
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   105
                             objtype: PgipTypes.objtype, 
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   106
                             name: PgipTypes.objname }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   107
       | Askguise       of { }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   108
       | Parsescript    of { text: string, location: location,
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   109
                             systemdata: string option } 
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   110
       | Showproofstate of { }
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   111
       | Showctxt       of { }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   112
       | Searchtheorems of { arg: string }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   113
       | Setlinewidth   of { width: int }
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   114
       | Viewdoc        of { arg: string }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   115
       (* improper theory-level commands *)
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   116
       | Doitem         of { text: string }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   117
       | Undoitem       of { }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   118
       | Redoitem       of { }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   119
       | Aborttheory    of { }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   120
       | Retracttheory  of { thyname: string }
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   121
       | Loadfile       of { url: pgipurl }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   122
       | Openfile       of { url: pgipurl }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   123
       | Closefile      of { }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   124
       | Abortfile      of { }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   125
       | Retractfile    of { url: pgipurl }
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   126
       | Changecwd      of { url: pgipurl }
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   127
       | Systemcmd      of { arg: string }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   128
       (* unofficial escape command for debugging *)
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   129
       | Quitpgip       of { }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   130
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   131
(* Extracting content from input XML elements to make a PGIPinput *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   132
local
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   133
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   134
    val thyname_attro = get_attr_opt "thyname"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   135
    val thyname_attr = get_attr "thyname"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   136
    val name_attr = get_attr "name"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   137
    val name_attro = get_attr_opt "name"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   138
    val thmname_attr = get_attr "thmname"
22406
a591df440b5b Add setproverflag, to replace other flag controls
aspinall
parents: 22161
diff changeset
   139
    val flagname_attr = get_attr "flagname"
a591df440b5b Add setproverflag, to replace other flag controls
aspinall
parents: 22161
diff changeset
   140
    val value_attr = get_attr "value"
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   141
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
   142
    fun objtype_attro attrs = if has_attr "objtype" attrs then
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   143
                                  SOME (objtype_of_attrs attrs)
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   144
                              else NONE
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
   145
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
   146
    fun pgipurl_attro attrs = if has_attr "url" attrs then
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   147
                                  SOME (pgipurl_of_attrs attrs)
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   148
                              else NONE
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
   149
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   150
    val times_attr = read_pgipnat o (get_attr_dflt "times" "1")
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   151
    val prefcat_attr = get_attr_opt "prefcategory"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   152
21940
fbd068dd4d29 minor tuning;
wenzelm
parents: 21867
diff changeset
   153
    fun xmltext (XML.Text text :: ts) = text ^ xmltext ts
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   154
      | xmltext [] = ""
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   155
      | xmltext _ = raise PGIP "Expected text (PCDATA/CDATA)"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   156
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   157
    exception Unknown
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   158
    exception NoAction
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   159
in
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   160
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   161
(* Return a valid PGIP input command.
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   162
   Raise PGIP exception for invalid data.
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   163
   Return NONE for unknown/unhandled commands. 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   164
*)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   165
fun input (elem, attrs, data) =
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   166
SOME 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   167
 (case elem of 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   168
     "askpgip"        => Askpgip { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   169
   | "askpgml"        => Askpgml { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   170
   | "askconfig"      => Askconfig { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   171
   (* proverconfig *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   172
   | "askprefs"       => Askprefs { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   173
   | "getpref"        => Getpref { name = name_attr attrs, 
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   174
                                   prefcategory = prefcat_attr attrs }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   175
   | "setpref"        => Setpref { name = name_attr attrs, 
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   176
                                   prefcategory = prefcat_attr attrs,
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   177
                                   value = xmltext data }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   178
   (* provercontrol *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   179
   | "proverinit"     => Proverinit { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   180
   | "proverexit"     => Proverexit { }
22406
a591df440b5b Add setproverflag, to replace other flag controls
aspinall
parents: 22161
diff changeset
   181
   | "setproverflag"  => Setproverflag { flagname = flagname_attr attrs,
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   182
                                         value = read_pgipbool (value_attr attrs) }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   183
   (* improperproofcmd: improper commands not in script *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   184
   | "dostep"         => Dostep    { text = xmltext data }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   185
   | "undostep"       => Undostep  { times = times_attr attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   186
   | "redostep"       => Redostep  { } 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   187
   | "abortgoal"      => Abortgoal { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   188
   | "forget"         => Forget { thyname = thyname_attro attrs, 
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   189
                                  name = name_attro attrs,
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   190
                                  objtype = objtype_attro attrs }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   191
   | "restoregoal"    => Restoregoal { thmname = thmname_attr attrs}
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   192
   (* proofctxt: improper commands *)
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21655
diff changeset
   193
   | "askids"         => Askids { url = pgipurl_attro attrs,
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   194
                                  thyname = thyname_attro attrs, 
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   195
                                  objtype = objtype_attro attrs }
22161
b2117f4f2d39 Add askrefs, setrefs, error_with_pos
aspinall
parents: 22083
diff changeset
   196
   | "askrefs"        => Askrefs { url = pgipurl_attro attrs,
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   197
                                   thyname = thyname_attro attrs, 
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   198
                                   objtype = objtype_attro attrs,
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   199
                                   name = name_attro attrs }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   200
   | "showid"         => Showid { thyname = thyname_attro attrs,
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   201
                                  objtype = objtype_of_attrs attrs,
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   202
                                  name = name_attr attrs }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   203
   | "askguise"       => Askguise { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   204
   | "parsescript"    => Parsescript { text = (xmltext data),
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   205
                                       systemdata = get_attr_opt "systemdata" attrs,
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   206
                                       location = location_of_attrs attrs }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   207
   | "showproofstate" => Showproofstate { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   208
   | "showctxt"       => Showctxt { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   209
   | "searchtheorems" => Searchtheorems { arg = xmltext data }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   210
   | "setlinewidth"   => Setlinewidth   { width = read_pgipnat (xmltext data) }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   211
   | "viewdoc"        => Viewdoc { arg = xmltext data }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   212
   (* improperfilecmd: theory-level commands not in script *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   213
   | "doitem"         => Doitem  { text = xmltext data }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   214
   | "undoitem"       => Undoitem { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   215
   | "redoitem"       => Redoitem { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   216
   | "aborttheory"    => Aborttheory { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   217
   | "retracttheory"  => Retracttheory { thyname = thyname_attr attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   218
   | "loadfile"       => Loadfile { url = pgipurl_of_attrs attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   219
   | "openfile"       => Openfile { url = pgipurl_of_attrs attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   220
   | "closefile"      => Closefile { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   221
   | "abortfile"      => Abortfile { }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   222
   | "retractfile"    => Retractfile { url = pgipurl_of_attrs attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   223
   | "changecwd"      => Changecwd { url = pgipurl_of_attrs attrs }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   224
   | "systemcmd"      => Systemcmd { arg = xmltext data }
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   225
   (* unofficial command for debugging *)
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   226
   | "quitpgip" => Quitpgip { }
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   227
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   228
   (* We allow sending proper document markup too; we map it back to dostep   *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   229
   (* and strip out metainfo elements. Markup correctness isn't checked: this *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   230
   (* is a compatibility measure to make it easy for interfaces.              *)
21655
01b2d13153c8 Document structure in pgip_markup.ML. Minor fixes.
aspinall
parents: 21649
diff changeset
   231
   | x => if (x mem PgipMarkup.doc_markup_elements) then
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   232
              if (x mem PgipMarkup.doc_markup_elements_ignored) then
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   233
                  raise NoAction
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   234
              else 
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   235
                  Dostep { text = xmltext data } (* could separate out Doitem too *)
1ff5167592ba get rid of tabs;
wenzelm
parents: 26548
diff changeset
   236
          else raise Unknown) 
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   237
    handle Unknown => NONE | NoAction => NONE
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   238
end
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   239
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   240
end