src/Pure/PIDE/isabelle_markup.ML
author wenzelm
Wed Sep 12 13:21:33 2012 +0200 (2012-09-12 ago)
changeset 49321 a48f9bbbe720
parent 49036 4680c4046814
child 49358 0fa351b1bd14
permissions -rw-r--r--
avoid spaces in markup names, which might cause problems in boundary situations (e.g. HTML class);
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@48927
    29
  val theoryN: string
wenzelm@43548
    30
  val classN: string
wenzelm@46649
    31
  val type_nameN: string
wenzelm@43552
    32
  val constantN: string
wenzelm@45666
    33
  val fixedN: string val fixed: string -> Markup.T
wenzelm@45666
    34
  val dynamic_factN: string val dynamic_fact: string -> Markup.T
wenzelm@45666
    35
  val tfreeN: string val tfree: Markup.T
wenzelm@45666
    36
  val tvarN: string val tvar: Markup.T
wenzelm@45666
    37
  val freeN: string val free: Markup.T
wenzelm@45666
    38
  val skolemN: string val skolem: Markup.T
wenzelm@45666
    39
  val boundN: string val bound: Markup.T
wenzelm@45666
    40
  val varN: string val var: Markup.T
wenzelm@45666
    41
  val numeralN: string val numeral: Markup.T
wenzelm@45666
    42
  val literalN: string val literal: Markup.T
wenzelm@45666
    43
  val delimiterN: string val delimiter: Markup.T
wenzelm@45666
    44
  val inner_stringN: string val inner_string: Markup.T
wenzelm@45666
    45
  val inner_commentN: string val inner_comment: Markup.T
wenzelm@45666
    46
  val token_rangeN: string val token_range: Markup.T
wenzelm@45666
    47
  val sortN: string val sort: Markup.T
wenzelm@45666
    48
  val typN: string val typ: Markup.T
wenzelm@45666
    49
  val termN: string val term: Markup.T
wenzelm@45666
    50
  val propN: string val prop: Markup.T
wenzelm@45666
    51
  val typingN: string val typing: Markup.T
wenzelm@45666
    52
  val ML_keywordN: string val ML_keyword: Markup.T
wenzelm@45666
    53
  val ML_delimiterN: string val ML_delimiter: Markup.T
wenzelm@45666
    54
  val ML_tvarN: string val ML_tvar: Markup.T
wenzelm@45666
    55
  val ML_numeralN: string val ML_numeral: Markup.T
wenzelm@45666
    56
  val ML_charN: string val ML_char: Markup.T
wenzelm@45666
    57
  val ML_stringN: string val ML_string: Markup.T
wenzelm@45666
    58
  val ML_commentN: string val ML_comment: 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@49321
    67
  val document_antiquotationN: string
wenzelm@49321
    68
  val document_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 tokenN: string val token: Properties.T -> Markup.T
wenzelm@45674
    78
  val elapsedN: string
wenzelm@45674
    79
  val cpuN: string
wenzelm@45674
    80
  val gcN: string
wenzelm@45674
    81
  val timingN: string val timing: Timing.timing -> Markup.T
wenzelm@38721
    82
  val subgoalsN: string
wenzelm@45666
    83
  val proof_stateN: string val proof_state: int -> Markup.T
wenzelm@45666
    84
  val stateN: string val state: Markup.T
wenzelm@45666
    85
  val subgoalN: string val subgoal: Markup.T
wenzelm@45666
    86
  val sendbackN: string val sendback: Markup.T
wenzelm@45666
    87
  val hiliteN: string val hilite: Markup.T
wenzelm@29417
    88
  val taskN: string
wenzelm@47395
    89
  val acceptedN: string val accepted: Markup.T
wenzelm@45666
    90
  val forkedN: string val forked: Markup.T
wenzelm@45666
    91
  val joinedN: string val joined: Markup.T
wenzelm@49036
    92
  val runningN: string val running: Markup.T
wenzelm@49036
    93
  val finishedN: string val finished: Markup.T
wenzelm@45666
    94
  val failedN: string val failed: Markup.T
wenzelm@38871
    95
  val serialN: string
wenzelm@45666
    96
  val legacyN: string val legacy: Markup.T
wenzelm@45666
    97
  val promptN: string val prompt: Markup.T
wenzelm@45666
    98
  val reportN: string val report: Markup.T
wenzelm@45666
    99
  val no_reportN: string val no_report: Markup.T
wenzelm@48768
   100
  val badN: string val bad: Markup.T
wenzelm@43748
   101
  val functionN: string
wenzelm@44661
   102
  val assign_execs: Properties.T
wenzelm@44676
   103
  val removed_versions: Properties.T
wenzelm@43748
   104
  val invoke_scala: string -> string -> Properties.T
wenzelm@44298
   105
  val cancel_scala: string -> Properties.T
wenzelm@23623
   106
end;
wenzelm@23623
   107
wenzelm@45666
   108
structure Isabelle_Markup: ISABELLE_MARKUP =
wenzelm@23623
   109
struct
wenzelm@23623
   110
wenzelm@30221
   111
(** markup elements **)
wenzelm@30221
   112
wenzelm@45666
   113
fun markup_elem elem = (elem, (elem, []): Markup.T);
wenzelm@45666
   114
fun markup_string elem prop = (elem, fn s => (elem, [(prop, s)]): Markup.T);
wenzelm@45666
   115
fun markup_int elem prop = (elem, fn i => (elem, [(prop, Markup.print_int i)]): Markup.T);
wenzelm@23671
   116
wenzelm@23658
   117
wenzelm@33088
   118
(* formal entities *)
wenzelm@33088
   119
wenzelm@43547
   120
val (bindingN, binding) = markup_elem "binding";
wenzelm@42135
   121
wenzelm@42135
   122
val entityN = "entity";
wenzelm@45666
   123
fun entity kind name = (entityN, [(Markup.nameN, name), (Markup.kindN, kind)]);
wenzelm@33088
   124
wenzelm@43548
   125
fun get_entity_kind (name, props) =
wenzelm@45666
   126
  if name = entityN then AList.lookup (op =) props Markup.kindN
wenzelm@43548
   127
  else NONE;
wenzelm@43548
   128
wenzelm@33088
   129
val defN = "def";
wenzelm@33088
   130
val refN = "ref";
wenzelm@33088
   131
wenzelm@33088
   132
wenzelm@23671
   133
(* position *)
wenzelm@23671
   134
wenzelm@23671
   135
val lineN = "line";
wenzelm@27794
   136
val offsetN = "offset";
wenzelm@27794
   137
val end_offsetN = "end_offset";
wenzelm@23671
   138
val fileN = "file";
wenzelm@25816
   139
val idN = "id";
wenzelm@23671
   140
wenzelm@41484
   141
val position_properties' = [fileN, idN];
wenzelm@43710
   142
val position_properties = [lineN, offsetN, end_offsetN] @ position_properties';
wenzelm@27748
   143
wenzelm@25552
   144
val (positionN, position) = markup_elem "position";
wenzelm@26255
   145
wenzelm@23644
   146
wenzelm@43593
   147
(* path *)
wenzelm@43593
   148
wenzelm@45666
   149
val (pathN, path) = markup_string "path" Markup.nameN;
wenzelm@43593
   150
wenzelm@43593
   151
wenzelm@23644
   152
(* pretty printing *)
wenzelm@23644
   153
wenzelm@23644
   154
val indentN = "indent";
wenzelm@23644
   155
val (blockN, block) = markup_int "block" indentN;
wenzelm@23644
   156
wenzelm@23644
   157
val widthN = "width";
wenzelm@23644
   158
val (breakN, break) = markup_int "break" widthN;
wenzelm@23644
   159
wenzelm@25552
   160
val (fbreakN, fbreak) = markup_elem "fbreak";
wenzelm@23637
   161
wenzelm@23637
   162
wenzelm@33985
   163
(* hidden text *)
wenzelm@33985
   164
wenzelm@33985
   165
val (hiddenN, hidden) = markup_elem "hidden";
wenzelm@33985
   166
wenzelm@33985
   167
wenzelm@23623
   168
(* logical entities *)
wenzelm@23623
   169
wenzelm@48927
   170
val theoryN = "theory";
wenzelm@43548
   171
val classN = "class";
wenzelm@49321
   172
val type_nameN = "type_name";
wenzelm@43552
   173
val constantN = "constant";
wenzelm@43552
   174
wenzelm@45666
   175
val (fixedN, fixed) = markup_string "fixed" Markup.nameN;
wenzelm@45666
   176
val (dynamic_factN, dynamic_fact) = markup_string "dynamic_fact" Markup.nameN;
wenzelm@23623
   177
wenzelm@23623
   178
wenzelm@23623
   179
(* inner syntax *)
wenzelm@23623
   180
wenzelm@25552
   181
val (tfreeN, tfree) = markup_elem "tfree";
wenzelm@25552
   182
val (tvarN, tvar) = markup_elem "tvar";
wenzelm@25552
   183
val (freeN, free) = markup_elem "free";
wenzelm@25552
   184
val (skolemN, skolem) = markup_elem "skolem";
wenzelm@25552
   185
val (boundN, bound) = markup_elem "bound";
wenzelm@25552
   186
val (varN, var) = markup_elem "var";
wenzelm@29318
   187
val (numeralN, numeral) = markup_elem "numeral";
wenzelm@27804
   188
val (literalN, literal) = markup_elem "literal";
wenzelm@43432
   189
val (delimiterN, delimiter) = markup_elem "delimiter";
wenzelm@29318
   190
val (inner_stringN, inner_string) = markup_elem "inner_string";
wenzelm@27883
   191
val (inner_commentN, inner_comment) = markup_elem "inner_comment";
wenzelm@23719
   192
wenzelm@39168
   193
val (token_rangeN, token_range) = markup_elem "token_range";
wenzelm@39168
   194
wenzelm@25552
   195
val (sortN, sort) = markup_elem "sort";
wenzelm@25552
   196
val (typN, typ) = markup_elem "typ";
wenzelm@25552
   197
val (termN, term) = markup_elem "term";
wenzelm@27818
   198
val (propN, prop) = markup_elem "prop";
wenzelm@27748
   199
wenzelm@45445
   200
val (typingN, typing) = markup_elem "typing";
wenzelm@45445
   201
wenzelm@23623
   202
wenzelm@30614
   203
(* ML syntax *)
wenzelm@30614
   204
wenzelm@30614
   205
val (ML_keywordN, ML_keyword) = markup_elem "ML_keyword";
wenzelm@37195
   206
val (ML_delimiterN, ML_delimiter) = markup_elem "ML_delimiter";
wenzelm@30614
   207
val (ML_tvarN, ML_tvar) = markup_elem "ML_tvar";
wenzelm@30614
   208
val (ML_numeralN, ML_numeral) = markup_elem "ML_numeral";
wenzelm@30614
   209
val (ML_charN, ML_char) = markup_elem "ML_char";
wenzelm@30614
   210
val (ML_stringN, ML_string) = markup_elem "ML_string";
wenzelm@30614
   211
val (ML_commentN, ML_comment) = markup_elem "ML_comment";
wenzelm@30614
   212
wenzelm@42327
   213
val ML_defN = "ML_def";
wenzelm@42327
   214
val ML_openN = "ML_open";
wenzelm@42327
   215
val ML_structN = "ML_struct";
wenzelm@30702
   216
val (ML_typingN, ML_typing) = markup_elem "ML_typing";
wenzelm@30702
   217
wenzelm@30614
   218
wenzelm@27875
   219
(* embedded source text *)
wenzelm@27875
   220
wenzelm@27875
   221
val (ML_sourceN, ML_source) = markup_elem "ML_source";
wenzelm@27875
   222
val (doc_sourceN, doc_source) = markup_elem "doc_source";
wenzelm@27875
   223
wenzelm@27879
   224
val (antiqN, antiq) = markup_elem "antiq";
wenzelm@49321
   225
val ML_antiquotationN = "ML_antiquotation";
wenzelm@49321
   226
val document_antiquotationN = "document_antiquotation";
wenzelm@49321
   227
val document_antiquotation_optionN = "document_antiquotation_option";
wenzelm@27879
   228
wenzelm@27875
   229
wenzelm@23623
   230
(* outer syntax *)
wenzelm@23623
   231
wenzelm@37193
   232
val (keywordN, keyword) = markup_elem "keyword";
wenzelm@37192
   233
val (operatorN, operator) = markup_elem "operator";
wenzelm@37193
   234
val (commandN, command) = markup_elem "command";
wenzelm@25552
   235
val (stringN, string) = markup_elem "string";
wenzelm@25552
   236
val (altstringN, altstring) = markup_elem "altstring";
wenzelm@25552
   237
val (verbatimN, verbatim) = markup_elem "verbatim";
wenzelm@25552
   238
val (commentN, comment) = markup_elem "comment";
wenzelm@25552
   239
val (controlN, control) = markup_elem "control";
wenzelm@23719
   240
wenzelm@38229
   241
val tokenN = "token";
wenzelm@38229
   242
fun token props = (tokenN, props);
wenzelm@27851
   243
wenzelm@23623
   244
wenzelm@45674
   245
(* timing *)
wenzelm@45674
   246
wenzelm@45674
   247
val timingN = "timing";
wenzelm@45674
   248
val elapsedN = "elapsed";
wenzelm@45674
   249
val cpuN = "cpu";
wenzelm@45674
   250
val gcN = "gc";
wenzelm@45674
   251
wenzelm@45674
   252
fun timing {elapsed, cpu, gc} =
wenzelm@45674
   253
  (timingN,
wenzelm@45674
   254
   [(elapsedN, Time.toString elapsed),
wenzelm@45674
   255
    (cpuN, Time.toString cpu),
wenzelm@45674
   256
    (gcN, Time.toString gc)]);
wenzelm@45674
   257
wenzelm@45674
   258
wenzelm@40394
   259
(* toplevel *)
wenzelm@40391
   260
wenzelm@38721
   261
val subgoalsN = "subgoals";
wenzelm@38721
   262
val (proof_stateN, proof_state) = markup_int "proof_state" subgoalsN;
wenzelm@38721
   263
wenzelm@25552
   264
val (stateN, state) = markup_elem "state";
wenzelm@25552
   265
val (subgoalN, subgoal) = markup_elem "subgoal";
wenzelm@25552
   266
val (sendbackN, sendback) = markup_elem "sendback";
wenzelm@25552
   267
val (hiliteN, hilite) = markup_elem "hilite";
wenzelm@25552
   268
wenzelm@25552
   269
wenzelm@27606
   270
(* command status *)
wenzelm@27606
   271
wenzelm@29417
   272
val taskN = "task";
wenzelm@29417
   273
wenzelm@47395
   274
val (acceptedN, accepted) = markup_elem "accepted";
wenzelm@37186
   275
val (forkedN, forked) = markup_elem "forked";
wenzelm@37186
   276
val (joinedN, joined) = markup_elem "joined";
wenzelm@49036
   277
val (runningN, running) = markup_elem "running";
wenzelm@49036
   278
val (finishedN, finished) = markup_elem "finished";
wenzelm@27615
   279
val (failedN, failed) = markup_elem "failed";
wenzelm@27606
   280
wenzelm@29488
   281
wenzelm@27969
   282
(* messages *)
wenzelm@27969
   283
wenzelm@38871
   284
val serialN = "serial";
wenzelm@27969
   285
wenzelm@44549
   286
val (legacyN, legacy) = markup_elem "legacy";
wenzelm@27969
   287
val (promptN, prompt) = markup_elem "prompt";
wenzelm@27969
   288
wenzelm@38887
   289
val (reportN, report) = markup_elem "report";
wenzelm@39439
   290
val (no_reportN, no_report) = markup_elem "no_report";
wenzelm@38887
   291
wenzelm@48768
   292
val (badN, bad) = markup_elem "bad";
wenzelm@39171
   293
wenzelm@27969
   294
wenzelm@46774
   295
(* protocol message functions *)
wenzelm@43748
   296
wenzelm@43748
   297
val functionN = "function"
wenzelm@43748
   298
wenzelm@44661
   299
val assign_execs = [(functionN, "assign_execs")];
wenzelm@44676
   300
val removed_versions = [(functionN, "removed_versions")];
wenzelm@44661
   301
wenzelm@45666
   302
fun invoke_scala name id = [(functionN, "invoke_scala"), (Markup.nameN, name), (idN, id)];
wenzelm@44298
   303
fun cancel_scala id = [(functionN, "cancel_scala"), (idN, id)];
wenzelm@43748
   304
wenzelm@23623
   305
end;