src/Pure/PIDE/isabelle_markup.ML
author wenzelm
Thu Aug 02 12:36:54 2012 +0200 (2012-08-02)
changeset 48646 91281e9472d8
parent 47395 e6261a493f04
child 48709 719f458cd89e
permissions -rw-r--r--
more official command specifications, including source position;
wenzelm@45670
     1
(*  Title:      Pure/PIDE/isabelle_markup.ML
wenzelm@23623
     2
    Author:     Makarius
wenzelm@23623
     3
wenzelm@45666
     4
Isabelle markup elements.
wenzelm@23623
     5
*)
wenzelm@23623
     6
wenzelm@45666
     7
signature ISABELLE_MARKUP =
wenzelm@23623
     8
sig
wenzelm@45666
     9
  val bindingN: string val binding: Markup.T
wenzelm@45666
    10
  val entityN: string val entity: string -> string -> Markup.T
wenzelm@45666
    11
  val get_entity_kind: Markup.T -> string option
wenzelm@33088
    12
  val defN: string
wenzelm@33088
    13
  val refN: string
wenzelm@23671
    14
  val lineN: string
wenzelm@27794
    15
  val offsetN: string
wenzelm@27794
    16
  val end_offsetN: string
wenzelm@23671
    17
  val fileN: string
wenzelm@30221
    18
  val idN: string
wenzelm@27748
    19
  val position_properties': string list
wenzelm@26051
    20
  val position_properties: string list
wenzelm@45666
    21
  val positionN: string val position: Markup.T
wenzelm@45666
    22
  val pathN: string val path: string -> Markup.T
wenzelm@23644
    23
  val indentN: string
wenzelm@45666
    24
  val blockN: string val block: int -> Markup.T
aspinall@23695
    25
  val widthN: string
wenzelm@45666
    26
  val breakN: string val break: int -> Markup.T
wenzelm@45666
    27
  val fbreakN: string val fbreak: Markup.T
wenzelm@45666
    28
  val hiddenN: string val hidden: Markup.T
wenzelm@43548
    29
  val classN: string
wenzelm@46649
    30
  val type_nameN: string
wenzelm@43552
    31
  val constantN: string
wenzelm@45666
    32
  val fixedN: string val fixed: string -> Markup.T
wenzelm@45666
    33
  val dynamic_factN: string val dynamic_fact: string -> Markup.T
wenzelm@45666
    34
  val tfreeN: string val tfree: Markup.T
wenzelm@45666
    35
  val tvarN: string val tvar: Markup.T
wenzelm@45666
    36
  val freeN: string val free: Markup.T
wenzelm@45666
    37
  val skolemN: string val skolem: Markup.T
wenzelm@45666
    38
  val boundN: string val bound: Markup.T
wenzelm@45666
    39
  val varN: string val var: Markup.T
wenzelm@45666
    40
  val numeralN: string val numeral: Markup.T
wenzelm@45666
    41
  val literalN: string val literal: Markup.T
wenzelm@45666
    42
  val delimiterN: string val delimiter: Markup.T
wenzelm@45666
    43
  val inner_stringN: string val inner_string: Markup.T
wenzelm@45666
    44
  val inner_commentN: string val inner_comment: Markup.T
wenzelm@45666
    45
  val token_rangeN: string val token_range: Markup.T
wenzelm@45666
    46
  val sortN: string val sort: Markup.T
wenzelm@45666
    47
  val typN: string val typ: Markup.T
wenzelm@45666
    48
  val termN: string val term: Markup.T
wenzelm@45666
    49
  val propN: string val prop: Markup.T
wenzelm@45666
    50
  val typingN: string val typing: Markup.T
wenzelm@45666
    51
  val ML_keywordN: string val ML_keyword: Markup.T
wenzelm@45666
    52
  val ML_delimiterN: string val ML_delimiter: Markup.T
wenzelm@45666
    53
  val ML_tvarN: string val ML_tvar: Markup.T
wenzelm@45666
    54
  val ML_numeralN: string val ML_numeral: Markup.T
wenzelm@45666
    55
  val ML_charN: string val ML_char: Markup.T
wenzelm@45666
    56
  val ML_stringN: string val ML_string: Markup.T
wenzelm@45666
    57
  val ML_commentN: string val ML_comment: Markup.T
wenzelm@45666
    58
  val ML_malformedN: string val ML_malformed: Markup.T
wenzelm@42327
    59
  val ML_defN: string
wenzelm@42327
    60
  val ML_openN: string
wenzelm@42327
    61
  val ML_structN: string
wenzelm@45666
    62
  val ML_typingN: string val ML_typing: Markup.T
wenzelm@45666
    63
  val ML_sourceN: string val ML_source: Markup.T
wenzelm@45666
    64
  val doc_sourceN: string val doc_source: Markup.T
wenzelm@45666
    65
  val antiqN: string val antiq: Markup.T
wenzelm@43560
    66
  val ML_antiquotationN: string
wenzelm@43564
    67
  val doc_antiquotationN: string
wenzelm@43564
    68
  val doc_antiquotation_optionN: string
wenzelm@45666
    69
  val keywordN: string val keyword: Markup.T
wenzelm@45666
    70
  val operatorN: string val operator: Markup.T
wenzelm@45666
    71
  val commandN: string val command: Markup.T
wenzelm@45666
    72
  val stringN: string val string: Markup.T
wenzelm@45666
    73
  val altstringN: string val altstring: Markup.T
wenzelm@45666
    74
  val verbatimN: string val verbatim: Markup.T
wenzelm@45666
    75
  val commentN: string val comment: Markup.T
wenzelm@45666
    76
  val controlN: string val control: Markup.T
wenzelm@45666
    77
  val malformedN: string val malformed: Markup.T
wenzelm@45666
    78
  val tokenN: string val token: Properties.T -> Markup.T
wenzelm@45666
    79
  val command_spanN: string val command_span: string -> Markup.T
wenzelm@45666
    80
  val ignored_spanN: string val ignored_span: Markup.T
wenzelm@45666
    81
  val malformed_spanN: string val malformed_span: Markup.T
wenzelm@45674
    82
  val elapsedN: string
wenzelm@45674
    83
  val cpuN: string
wenzelm@45674
    84
  val gcN: string
wenzelm@45674
    85
  val timingN: string val timing: Timing.timing -> Markup.T
wenzelm@38721
    86
  val subgoalsN: string
wenzelm@45666
    87
  val proof_stateN: string val proof_state: int -> Markup.T
wenzelm@45666
    88
  val stateN: string val state: Markup.T
wenzelm@45666
    89
  val subgoalN: string val subgoal: Markup.T
wenzelm@45666
    90
  val sendbackN: string val sendback: Markup.T
wenzelm@45666
    91
  val hiliteN: string val hilite: Markup.T
wenzelm@29417
    92
  val taskN: string
wenzelm@47395
    93
  val acceptedN: string val accepted: Markup.T
wenzelm@45666
    94
  val forkedN: string val forked: Markup.T
wenzelm@45666
    95
  val joinedN: string val joined: Markup.T
wenzelm@45666
    96
  val failedN: string val failed: Markup.T
wenzelm@45666
    97
  val finishedN: string val finished: Markup.T
wenzelm@38871
    98
  val serialN: string
wenzelm@45666
    99
  val legacyN: string val legacy: Markup.T
wenzelm@45666
   100
  val promptN: string val prompt: Markup.T
wenzelm@45666
   101
  val reportN: string val report: Markup.T
wenzelm@45666
   102
  val no_reportN: string val no_report: Markup.T
wenzelm@45666
   103
  val badN: string val bad: Markup.T
wenzelm@43748
   104
  val functionN: string
wenzelm@46121
   105
  val ready: Properties.T
wenzelm@46122
   106
  val loaded_theory: string -> Properties.T
wenzelm@46123
   107
  val keyword_decl: string -> Properties.T
wenzelm@46123
   108
  val command_decl: string -> string -> Properties.T
wenzelm@44661
   109
  val assign_execs: Properties.T
wenzelm@44676
   110
  val removed_versions: Properties.T
wenzelm@43748
   111
  val invoke_scala: string -> string -> Properties.T
wenzelm@44298
   112
  val cancel_scala: string -> Properties.T
wenzelm@23623
   113
end;
wenzelm@23623
   114
wenzelm@45666
   115
structure Isabelle_Markup: ISABELLE_MARKUP =
wenzelm@23623
   116
struct
wenzelm@23623
   117
wenzelm@30221
   118
(** markup elements **)
wenzelm@30221
   119
wenzelm@45666
   120
fun markup_elem elem = (elem, (elem, []): Markup.T);
wenzelm@45666
   121
fun markup_string elem prop = (elem, fn s => (elem, [(prop, s)]): Markup.T);
wenzelm@45666
   122
fun markup_int elem prop = (elem, fn i => (elem, [(prop, Markup.print_int i)]): Markup.T);
wenzelm@23671
   123
wenzelm@23658
   124
wenzelm@33088
   125
(* formal entities *)
wenzelm@33088
   126
wenzelm@43547
   127
val (bindingN, binding) = markup_elem "binding";
wenzelm@42135
   128
wenzelm@42135
   129
val entityN = "entity";
wenzelm@45666
   130
fun entity kind name = (entityN, [(Markup.nameN, name), (Markup.kindN, kind)]);
wenzelm@33088
   131
wenzelm@43548
   132
fun get_entity_kind (name, props) =
wenzelm@45666
   133
  if name = entityN then AList.lookup (op =) props Markup.kindN
wenzelm@43548
   134
  else NONE;
wenzelm@43548
   135
wenzelm@33088
   136
val defN = "def";
wenzelm@33088
   137
val refN = "ref";
wenzelm@33088
   138
wenzelm@33088
   139
wenzelm@23671
   140
(* position *)
wenzelm@23671
   141
wenzelm@23671
   142
val lineN = "line";
wenzelm@27794
   143
val offsetN = "offset";
wenzelm@27794
   144
val end_offsetN = "end_offset";
wenzelm@23671
   145
val fileN = "file";
wenzelm@25816
   146
val idN = "id";
wenzelm@23671
   147
wenzelm@41484
   148
val position_properties' = [fileN, idN];
wenzelm@43710
   149
val position_properties = [lineN, offsetN, end_offsetN] @ position_properties';
wenzelm@27748
   150
wenzelm@25552
   151
val (positionN, position) = markup_elem "position";
wenzelm@26255
   152
wenzelm@23644
   153
wenzelm@43593
   154
(* path *)
wenzelm@43593
   155
wenzelm@45666
   156
val (pathN, path) = markup_string "path" Markup.nameN;
wenzelm@43593
   157
wenzelm@43593
   158
wenzelm@23644
   159
(* pretty printing *)
wenzelm@23644
   160
wenzelm@23644
   161
val indentN = "indent";
wenzelm@23644
   162
val (blockN, block) = markup_int "block" indentN;
wenzelm@23644
   163
wenzelm@23644
   164
val widthN = "width";
wenzelm@23644
   165
val (breakN, break) = markup_int "break" widthN;
wenzelm@23644
   166
wenzelm@25552
   167
val (fbreakN, fbreak) = markup_elem "fbreak";
wenzelm@23637
   168
wenzelm@23637
   169
wenzelm@33985
   170
(* hidden text *)
wenzelm@33985
   171
wenzelm@33985
   172
val (hiddenN, hidden) = markup_elem "hidden";
wenzelm@33985
   173
wenzelm@33985
   174
wenzelm@23623
   175
(* logical entities *)
wenzelm@23623
   176
wenzelm@43548
   177
val classN = "class";
wenzelm@46649
   178
val type_nameN = "type name";
wenzelm@43552
   179
val constantN = "constant";
wenzelm@43552
   180
wenzelm@45666
   181
val (fixedN, fixed) = markup_string "fixed" Markup.nameN;
wenzelm@45666
   182
val (dynamic_factN, dynamic_fact) = markup_string "dynamic_fact" Markup.nameN;
wenzelm@23623
   183
wenzelm@23623
   184
wenzelm@23623
   185
(* inner syntax *)
wenzelm@23623
   186
wenzelm@25552
   187
val (tfreeN, tfree) = markup_elem "tfree";
wenzelm@25552
   188
val (tvarN, tvar) = markup_elem "tvar";
wenzelm@25552
   189
val (freeN, free) = markup_elem "free";
wenzelm@25552
   190
val (skolemN, skolem) = markup_elem "skolem";
wenzelm@25552
   191
val (boundN, bound) = markup_elem "bound";
wenzelm@25552
   192
val (varN, var) = markup_elem "var";
wenzelm@29318
   193
val (numeralN, numeral) = markup_elem "numeral";
wenzelm@27804
   194
val (literalN, literal) = markup_elem "literal";
wenzelm@43432
   195
val (delimiterN, delimiter) = markup_elem "delimiter";
wenzelm@29318
   196
val (inner_stringN, inner_string) = markup_elem "inner_string";
wenzelm@27883
   197
val (inner_commentN, inner_comment) = markup_elem "inner_comment";
wenzelm@23719
   198
wenzelm@39168
   199
val (token_rangeN, token_range) = markup_elem "token_range";
wenzelm@39168
   200
wenzelm@25552
   201
val (sortN, sort) = markup_elem "sort";
wenzelm@25552
   202
val (typN, typ) = markup_elem "typ";
wenzelm@25552
   203
val (termN, term) = markup_elem "term";
wenzelm@27818
   204
val (propN, prop) = markup_elem "prop";
wenzelm@27748
   205
wenzelm@45445
   206
val (typingN, typing) = markup_elem "typing";
wenzelm@45445
   207
wenzelm@23623
   208
wenzelm@30614
   209
(* ML syntax *)
wenzelm@30614
   210
wenzelm@30614
   211
val (ML_keywordN, ML_keyword) = markup_elem "ML_keyword";
wenzelm@37195
   212
val (ML_delimiterN, ML_delimiter) = markup_elem "ML_delimiter";
wenzelm@30614
   213
val (ML_tvarN, ML_tvar) = markup_elem "ML_tvar";
wenzelm@30614
   214
val (ML_numeralN, ML_numeral) = markup_elem "ML_numeral";
wenzelm@30614
   215
val (ML_charN, ML_char) = markup_elem "ML_char";
wenzelm@30614
   216
val (ML_stringN, ML_string) = markup_elem "ML_string";
wenzelm@30614
   217
val (ML_commentN, ML_comment) = markup_elem "ML_comment";
wenzelm@30614
   218
val (ML_malformedN, ML_malformed) = markup_elem "ML_malformed";
wenzelm@30614
   219
wenzelm@42327
   220
val ML_defN = "ML_def";
wenzelm@42327
   221
val ML_openN = "ML_open";
wenzelm@42327
   222
val ML_structN = "ML_struct";
wenzelm@30702
   223
val (ML_typingN, ML_typing) = markup_elem "ML_typing";
wenzelm@30702
   224
wenzelm@30614
   225
wenzelm@27875
   226
(* embedded source text *)
wenzelm@27875
   227
wenzelm@27875
   228
val (ML_sourceN, ML_source) = markup_elem "ML_source";
wenzelm@27875
   229
val (doc_sourceN, doc_source) = markup_elem "doc_source";
wenzelm@27875
   230
wenzelm@27879
   231
val (antiqN, antiq) = markup_elem "antiq";
wenzelm@43560
   232
val ML_antiquotationN = "ML antiquotation";
wenzelm@43564
   233
val doc_antiquotationN = "document antiquotation";
wenzelm@43564
   234
val doc_antiquotation_optionN = "document antiquotation option";
wenzelm@27879
   235
wenzelm@27875
   236
wenzelm@23623
   237
(* outer syntax *)
wenzelm@23623
   238
wenzelm@37193
   239
val (keywordN, keyword) = markup_elem "keyword";
wenzelm@37192
   240
val (operatorN, operator) = markup_elem "operator";
wenzelm@37193
   241
val (commandN, command) = markup_elem "command";
wenzelm@25552
   242
val (stringN, string) = markup_elem "string";
wenzelm@25552
   243
val (altstringN, altstring) = markup_elem "altstring";
wenzelm@25552
   244
val (verbatimN, verbatim) = markup_elem "verbatim";
wenzelm@25552
   245
val (commentN, comment) = markup_elem "comment";
wenzelm@25552
   246
val (controlN, control) = markup_elem "control";
wenzelm@25552
   247
val (malformedN, malformed) = markup_elem "malformed";
wenzelm@23719
   248
wenzelm@38229
   249
val tokenN = "token";
wenzelm@38229
   250
fun token props = (tokenN, props);
wenzelm@27851
   251
wenzelm@45666
   252
val (command_spanN, command_span) = markup_string "command_span" Markup.nameN;
wenzelm@27660
   253
val (ignored_spanN, ignored_span) = markup_elem "ignored_span";
wenzelm@27836
   254
val (malformed_spanN, malformed_span) = markup_elem "malformed_span";
wenzelm@23719
   255
wenzelm@23623
   256
wenzelm@45674
   257
(* timing *)
wenzelm@45674
   258
wenzelm@45674
   259
val timingN = "timing";
wenzelm@45674
   260
val elapsedN = "elapsed";
wenzelm@45674
   261
val cpuN = "cpu";
wenzelm@45674
   262
val gcN = "gc";
wenzelm@45674
   263
wenzelm@45674
   264
fun timing {elapsed, cpu, gc} =
wenzelm@45674
   265
  (timingN,
wenzelm@45674
   266
   [(elapsedN, Time.toString elapsed),
wenzelm@45674
   267
    (cpuN, Time.toString cpu),
wenzelm@45674
   268
    (gcN, Time.toString gc)]);
wenzelm@45674
   269
wenzelm@45674
   270
wenzelm@40394
   271
(* toplevel *)
wenzelm@40391
   272
wenzelm@38721
   273
val subgoalsN = "subgoals";
wenzelm@38721
   274
val (proof_stateN, proof_state) = markup_int "proof_state" subgoalsN;
wenzelm@38721
   275
wenzelm@25552
   276
val (stateN, state) = markup_elem "state";
wenzelm@25552
   277
val (subgoalN, subgoal) = markup_elem "subgoal";
wenzelm@25552
   278
val (sendbackN, sendback) = markup_elem "sendback";
wenzelm@25552
   279
val (hiliteN, hilite) = markup_elem "hilite";
wenzelm@25552
   280
wenzelm@25552
   281
wenzelm@27606
   282
(* command status *)
wenzelm@27606
   283
wenzelm@29417
   284
val taskN = "task";
wenzelm@29417
   285
wenzelm@47395
   286
val (acceptedN, accepted) = markup_elem "accepted";
wenzelm@37186
   287
val (forkedN, forked) = markup_elem "forked";
wenzelm@37186
   288
val (joinedN, joined) = markup_elem "joined";
wenzelm@38429
   289
wenzelm@27615
   290
val (failedN, failed) = markup_elem "failed";
wenzelm@27606
   291
val (finishedN, finished) = markup_elem "finished";
wenzelm@27606
   292
wenzelm@29488
   293
wenzelm@27969
   294
(* messages *)
wenzelm@27969
   295
wenzelm@38871
   296
val serialN = "serial";
wenzelm@27969
   297
wenzelm@44549
   298
val (legacyN, legacy) = markup_elem "legacy";
wenzelm@27969
   299
val (promptN, prompt) = markup_elem "prompt";
wenzelm@27969
   300
wenzelm@38887
   301
val (reportN, report) = markup_elem "report";
wenzelm@39439
   302
val (no_reportN, no_report) = markup_elem "no_report";
wenzelm@38887
   303
wenzelm@39171
   304
val (badN, bad) = markup_elem "bad";
wenzelm@39171
   305
wenzelm@27969
   306
wenzelm@46774
   307
(* protocol message functions *)
wenzelm@43748
   308
wenzelm@43748
   309
val functionN = "function"
wenzelm@43748
   310
wenzelm@46121
   311
val ready = [(functionN, "ready")];
wenzelm@46121
   312
wenzelm@46122
   313
fun loaded_theory name = [(functionN, "loaded_theory"), (Markup.nameN, name)];
wenzelm@46122
   314
wenzelm@46123
   315
fun keyword_decl name = [(functionN, "keyword_decl"), (Markup.nameN, name)];
wenzelm@46123
   316
fun command_decl name kind =
wenzelm@46123
   317
  [(functionN, "command_decl"), (Markup.nameN, name), (Markup.kindN, kind)];
wenzelm@46123
   318
wenzelm@44661
   319
val assign_execs = [(functionN, "assign_execs")];
wenzelm@44676
   320
val removed_versions = [(functionN, "removed_versions")];
wenzelm@44661
   321
wenzelm@45666
   322
fun invoke_scala name id = [(functionN, "invoke_scala"), (Markup.nameN, name), (idN, id)];
wenzelm@44298
   323
fun cancel_scala id = [(functionN, "cancel_scala"), (idN, id)];
wenzelm@43748
   324
wenzelm@23623
   325
end;