src/Pure/PIDE/isabelle_markup.scala
author wenzelm
Tue Mar 13 21:17:37 2012 +0100 (2012-03-13 ago)
changeset 46910 3e068ef04b42
parent 46774 38f113b052b1
child 47395 e6261a493f04
permissions -rw-r--r--
clarified command state -- markup within proper_range, excluding trailing whitespace;
wenzelm@45670
     1
/*  Title:      Pure/PIDE/isabelle_markup.scala
wenzelm@27958
     2
    Author:     Makarius
wenzelm@27958
     3
wenzelm@45666
     4
Isabelle markup elements.
wenzelm@27958
     5
*/
wenzelm@27958
     6
wenzelm@27958
     7
package isabelle
wenzelm@27958
     8
wenzelm@27970
     9
wenzelm@45666
    10
object Isabelle_Markup
wenzelm@32450
    11
{
wenzelm@33088
    12
  /* formal entities */
wenzelm@33088
    13
wenzelm@38887
    14
  val BINDING = "binding"
wenzelm@33088
    15
  val ENTITY = "entity"
wenzelm@33088
    16
  val DEF = "def"
wenzelm@33088
    17
  val REF = "ref"
wenzelm@33088
    18
wenzelm@42202
    19
  object Entity
wenzelm@42202
    20
  {
wenzelm@42202
    21
    def unapply(markup: Markup): Option[(String, String)] =
wenzelm@42202
    22
      markup match {
wenzelm@45666
    23
        case Markup(ENTITY, props @ Markup.Kind(kind)) =>
wenzelm@42202
    24
          props match {
wenzelm@45666
    25
            case Markup.Name(name) => Some(kind, name)
wenzelm@42202
    26
            case _ => None
wenzelm@42202
    27
          }
wenzelm@42202
    28
        case _ => None
wenzelm@42202
    29
      }
wenzelm@42202
    30
  }
wenzelm@42202
    31
wenzelm@33088
    32
wenzelm@27970
    33
  /* position */
wenzelm@27970
    34
wenzelm@27970
    35
  val LINE = "line"
wenzelm@27970
    36
  val OFFSET = "offset"
wenzelm@27970
    37
  val END_OFFSET = "end_offset"
wenzelm@27970
    38
  val FILE = "file"
wenzelm@27970
    39
  val ID = "id"
wenzelm@27970
    40
wenzelm@42327
    41
  val DEF_LINE = "def_line"
wenzelm@42327
    42
  val DEF_OFFSET = "def_offset"
wenzelm@42327
    43
  val DEF_END_OFFSET = "def_end_offset"
wenzelm@42327
    44
  val DEF_FILE = "def_file"
wenzelm@42327
    45
  val DEF_ID = "def_id"
wenzelm@42327
    46
wenzelm@43710
    47
  val POSITION_PROPERTIES = Set(LINE, OFFSET, END_OFFSET, FILE, ID)
wenzelm@43593
    48
  val POSITION = "position"
wenzelm@29205
    49
wenzelm@43593
    50
wenzelm@43593
    51
  /* path */
wenzelm@43593
    52
wenzelm@43593
    53
  val PATH = "path"
wenzelm@43593
    54
wenzelm@43593
    55
  object Path
wenzelm@43593
    56
  {
wenzelm@43593
    57
    def unapply(markup: Markup): Option[String] =
wenzelm@43593
    58
      markup match {
wenzelm@45666
    59
        case Markup(PATH, Markup.Name(name)) => Some(name)
wenzelm@43593
    60
        case _ => None
wenzelm@43593
    61
      }
wenzelm@43593
    62
  }
wenzelm@29184
    63
wenzelm@29184
    64
wenzelm@36683
    65
  /* pretty printing */
wenzelm@36683
    66
wenzelm@43780
    67
  val Indent = new Properties.Int("indent")
wenzelm@36683
    68
  val BLOCK = "block"
wenzelm@43780
    69
  val Width = new Properties.Int("width")
wenzelm@36683
    70
  val BREAK = "break"
wenzelm@36683
    71
wenzelm@36683
    72
wenzelm@33985
    73
  /* hidden text */
wenzelm@33985
    74
wenzelm@33985
    75
  val HIDDEN = "hidden"
wenzelm@33985
    76
wenzelm@33985
    77
wenzelm@29184
    78
  /* logical entities */
wenzelm@29184
    79
wenzelm@43551
    80
  val CLASS = "class"
wenzelm@46649
    81
  val TYPE_NAME = "type name"
wenzelm@29184
    82
  val FIXED = "fixed"
wenzelm@43552
    83
  val CONSTANT = "constant"
wenzelm@43552
    84
wenzelm@29184
    85
  val DYNAMIC_FACT = "dynamic_fact"
wenzelm@29184
    86
wenzelm@29184
    87
wenzelm@29184
    88
  /* inner syntax */
wenzelm@29184
    89
wenzelm@29184
    90
  val TFREE = "tfree"
wenzelm@29184
    91
  val TVAR = "tvar"
wenzelm@29184
    92
  val FREE = "free"
wenzelm@29184
    93
  val SKOLEM = "skolem"
wenzelm@29184
    94
  val BOUND = "bound"
wenzelm@29184
    95
  val VAR = "var"
wenzelm@45702
    96
  val NUMERAL = "numeral"
wenzelm@29184
    97
  val LITERAL = "literal"
wenzelm@43432
    98
  val DELIMITER = "delimiter"
wenzelm@43386
    99
  val INNER_STRING = "inner_string"
wenzelm@29184
   100
  val INNER_COMMENT = "inner_comment"
wenzelm@29184
   101
wenzelm@39168
   102
  val TOKEN_RANGE = "token_range"
wenzelm@39168
   103
wenzelm@29184
   104
  val SORT = "sort"
wenzelm@29184
   105
  val TYP = "typ"
wenzelm@29184
   106
  val TERM = "term"
wenzelm@29184
   107
  val PROP = "prop"
wenzelm@29184
   108
wenzelm@45445
   109
  val TYPING = "typing"
wenzelm@45445
   110
wenzelm@29184
   111
  val ATTRIBUTE = "attribute"
wenzelm@29184
   112
  val METHOD = "method"
wenzelm@29184
   113
wenzelm@29184
   114
wenzelm@29184
   115
  /* embedded source text */
wenzelm@29184
   116
wenzelm@29184
   117
  val ML_SOURCE = "ML_source"
wenzelm@29184
   118
  val DOC_SOURCE = "doc_source"
wenzelm@29184
   119
wenzelm@29184
   120
  val ANTIQ = "antiq"
wenzelm@43560
   121
  val ML_ANTIQUOTATION = "ML antiquotation"
wenzelm@43564
   122
  val DOCUMENT_ANTIQUOTATION = "document antiquotation"
wenzelm@43564
   123
  val DOCUMENT_ANTIQUOTATION_OPTION = "document antiquotation option"
wenzelm@29184
   124
wenzelm@29184
   125
wenzelm@30615
   126
  /* ML syntax */
wenzelm@30615
   127
wenzelm@30615
   128
  val ML_KEYWORD = "ML_keyword"
wenzelm@37195
   129
  val ML_DELIMITER = "ML_delimiter"
wenzelm@30615
   130
  val ML_TVAR = "ML_tvar"
wenzelm@30615
   131
  val ML_NUMERAL = "ML_numeral"
wenzelm@30615
   132
  val ML_CHAR = "ML_char"
wenzelm@30615
   133
  val ML_STRING = "ML_string"
wenzelm@30615
   134
  val ML_COMMENT = "ML_comment"
wenzelm@30615
   135
  val ML_MALFORMED = "ML_malformed"
wenzelm@30615
   136
wenzelm@30702
   137
  val ML_DEF = "ML_def"
wenzelm@31472
   138
  val ML_OPEN = "ML_open"
wenzelm@31472
   139
  val ML_STRUCT = "ML_struct"
wenzelm@30702
   140
  val ML_TYPING = "ML_typing"
wenzelm@30702
   141
wenzelm@30615
   142
wenzelm@29184
   143
  /* outer syntax */
wenzelm@29184
   144
wenzelm@29184
   145
  val KEYWORD = "keyword"
wenzelm@37194
   146
  val OPERATOR = "operator"
wenzelm@29184
   147
  val COMMAND = "command"
wenzelm@29184
   148
  val STRING = "string"
wenzelm@29184
   149
  val ALTSTRING = "altstring"
wenzelm@29184
   150
  val VERBATIM = "verbatim"
wenzelm@29184
   151
  val COMMENT = "comment"
wenzelm@29184
   152
  val CONTROL = "control"
wenzelm@29184
   153
  val MALFORMED = "malformed"
wenzelm@29184
   154
wenzelm@29185
   155
  val COMMAND_SPAN = "command_span"
wenzelm@29185
   156
  val IGNORED_SPAN = "ignored_span"
wenzelm@29185
   157
  val MALFORMED_SPAN = "malformed_span"
wenzelm@29185
   158
wenzelm@29184
   159
wenzelm@45674
   160
  /* timing */
wenzelm@45674
   161
wenzelm@45674
   162
  val TIMING = "timing"
wenzelm@45674
   163
  val ELAPSED = "elapsed"
wenzelm@45674
   164
  val CPU = "cpu"
wenzelm@45674
   165
  val GC = "gc"
wenzelm@45674
   166
wenzelm@45674
   167
  object Timing
wenzelm@45674
   168
  {
wenzelm@45674
   169
    def apply(timing: isabelle.Timing): Markup =
wenzelm@45674
   170
      Markup(TIMING, List(
wenzelm@45674
   171
        (ELAPSED, Properties.Value.Double(timing.elapsed.seconds)),
wenzelm@45674
   172
        (CPU, Properties.Value.Double(timing.cpu.seconds)),
wenzelm@45674
   173
        (GC, Properties.Value.Double(timing.gc.seconds))))
wenzelm@45674
   174
    def unapply(markup: Markup): Option[isabelle.Timing] =
wenzelm@45674
   175
      markup match {
wenzelm@45674
   176
        case Markup(TIMING, List(
wenzelm@45674
   177
          (ELAPSED, Properties.Value.Double(elapsed)),
wenzelm@45674
   178
          (CPU, Properties.Value.Double(cpu)),
wenzelm@45674
   179
          (GC, Properties.Value.Double(gc)))) =>
wenzelm@45674
   180
            Some(new isabelle.Timing(Time.seconds(elapsed), Time.seconds(cpu), Time.seconds(gc)))
wenzelm@45674
   181
        case _ => None
wenzelm@45674
   182
      }
wenzelm@45674
   183
  }
wenzelm@45674
   184
wenzelm@45674
   185
wenzelm@29184
   186
  /* toplevel */
wenzelm@29184
   187
wenzelm@38721
   188
  val SUBGOALS = "subgoals"
wenzelm@38721
   189
  val PROOF_STATE = "proof_state"
wenzelm@38721
   190
wenzelm@29184
   191
  val STATE = "state"
wenzelm@29184
   192
  val SUBGOAL = "subgoal"
wenzelm@29184
   193
  val SENDBACK = "sendback"
wenzelm@29184
   194
  val HILITE = "hilite"
wenzelm@29184
   195
wenzelm@29184
   196
wenzelm@29184
   197
  /* command status */
wenzelm@29184
   198
wenzelm@29417
   199
  val TASK = "task"
wenzelm@29417
   200
wenzelm@46910
   201
  val PARSED = "parsed"
wenzelm@37186
   202
  val FORKED = "forked"
wenzelm@37186
   203
  val JOINED = "joined"
wenzelm@29184
   204
  val FAILED = "failed"
wenzelm@29184
   205
  val FINISHED = "finished"
wenzelm@29488
   206
wenzelm@29488
   207
wenzelm@29488
   208
  /* interactive documents */
wenzelm@29488
   209
wenzelm@38414
   210
  val VERSION = "version"
wenzelm@38414
   211
  val ASSIGN = "assign"
wenzelm@29184
   212
wenzelm@27970
   213
wenzelm@43721
   214
  /* prover process */
wenzelm@43721
   215
wenzelm@43721
   216
  val PROVER_COMMAND = "prover_command"
wenzelm@43721
   217
  val PROVER_ARG = "prover_arg"
wenzelm@43721
   218
wenzelm@43721
   219
wenzelm@27970
   220
  /* messages */
wenzelm@27970
   221
wenzelm@43780
   222
  val Serial = new Properties.Long("serial")
wenzelm@27970
   223
wenzelm@29195
   224
  val MESSAGE = "message"
wenzelm@29522
   225
wenzelm@29522
   226
  val INIT = "init"
wenzelm@29522
   227
  val STATUS = "status"
wenzelm@39525
   228
  val REPORT = "report"
wenzelm@29522
   229
  val WRITELN = "writeln"
wenzelm@29522
   230
  val TRACING = "tracing"
wenzelm@29522
   231
  val WARNING = "warning"
wenzelm@29522
   232
  val ERROR = "error"
wenzelm@46774
   233
  val PROTOCOL = "protocol"
wenzelm@29522
   234
  val SYSTEM = "system"
wenzelm@29522
   235
  val STDOUT = "stdout"
wenzelm@45633
   236
  val STDERR = "stderr"
wenzelm@29522
   237
  val EXIT = "exit"
wenzelm@29195
   238
wenzelm@44549
   239
  val LEGACY = "legacy"
wenzelm@44549
   240
wenzelm@39439
   241
  val NO_REPORT = "no_report"
wenzelm@39439
   242
wenzelm@39171
   243
  val BAD = "bad"
wenzelm@39171
   244
wenzelm@27970
   245
wenzelm@46774
   246
  /* protocol message functions */
wenzelm@43748
   247
wenzelm@43748
   248
  val FUNCTION = "function"
wenzelm@43780
   249
  val Function = new Properties.String(FUNCTION)
wenzelm@43748
   250
wenzelm@46121
   251
  val Ready: Properties.T = List((FUNCTION, "ready"))
wenzelm@46121
   252
wenzelm@46122
   253
  object Loaded_Theory
wenzelm@46122
   254
  {
wenzelm@46122
   255
    def unapply(props: Properties.T): Option[String] =
wenzelm@46122
   256
      props match {
wenzelm@46122
   257
        case List((FUNCTION, "loaded_theory"), (Markup.NAME, name)) => Some(name)
wenzelm@46122
   258
        case _ => None
wenzelm@46122
   259
      }
wenzelm@46122
   260
  }
wenzelm@46122
   261
wenzelm@46123
   262
  object Keyword_Decl
wenzelm@46123
   263
  {
wenzelm@46123
   264
    def unapply(props: Properties.T): Option[String] =
wenzelm@46123
   265
      props match {
wenzelm@46123
   266
        case List((FUNCTION, "keyword_decl"), (Markup.NAME, name)) => Some(name)
wenzelm@46123
   267
        case _ => None
wenzelm@46123
   268
      }
wenzelm@46123
   269
  }
wenzelm@46123
   270
  object Command_Decl
wenzelm@46123
   271
  {
wenzelm@46123
   272
    def unapply(props: Properties.T): Option[(String, String)] =
wenzelm@46123
   273
      props match {
wenzelm@46123
   274
        case List((FUNCTION, "command_decl"), (Markup.NAME, name), (Markup.KIND, kind)) =>
wenzelm@46123
   275
          Some((name, kind))
wenzelm@46123
   276
        case _ => None
wenzelm@46123
   277
      }
wenzelm@46123
   278
  }
wenzelm@46123
   279
wenzelm@44661
   280
  val Assign_Execs: Properties.T = List((FUNCTION, "assign_execs"))
wenzelm@44676
   281
  val Removed_Versions: Properties.T = List((FUNCTION, "removed_versions"))
wenzelm@44661
   282
wenzelm@43748
   283
  object Invoke_Scala
wenzelm@43748
   284
  {
wenzelm@43780
   285
    def unapply(props: Properties.T): Option[(String, String)] =
wenzelm@43748
   286
      props match {
wenzelm@46122
   287
        case List((FUNCTION, "invoke_scala"), (Markup.NAME, name), (ID, id)) => Some((name, id))
wenzelm@43748
   288
        case _ => None
wenzelm@43748
   289
      }
wenzelm@43748
   290
  }
wenzelm@44298
   291
  object Cancel_Scala
wenzelm@44298
   292
  {
wenzelm@44298
   293
    def unapply(props: Properties.T): Option[String] =
wenzelm@44298
   294
      props match {
wenzelm@46122
   295
        case List((FUNCTION, "cancel_scala"), (ID, id)) => Some(id)
wenzelm@44298
   296
        case _ => None
wenzelm@44298
   297
      }
wenzelm@44298
   298
  }
wenzelm@27958
   299
}
wenzelm@38230
   300