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