src/Pure/PIDE/isabelle_markup.scala
author wenzelm
Fri Aug 10 10:18:07 2012 +0200 (2012-08-10 ago)
changeset 48751 dc3bbdda4bc8
parent 48712 6b7a9bcc0bae
child 48752 8a81ef0bc790
permissions -rw-r--r--
more visible markup of malformed input as "bad";
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
wenzelm@30702
   136
  val ML_DEF = "ML_def"
wenzelm@31472
   137
  val ML_OPEN = "ML_open"
wenzelm@31472
   138
  val ML_STRUCT = "ML_struct"
wenzelm@30702
   139
  val ML_TYPING = "ML_typing"
wenzelm@30702
   140
wenzelm@30615
   141
wenzelm@29184
   142
  /* outer syntax */
wenzelm@29184
   143
wenzelm@29184
   144
  val KEYWORD = "keyword"
wenzelm@37194
   145
  val OPERATOR = "operator"
wenzelm@29184
   146
  val COMMAND = "command"
wenzelm@29184
   147
  val STRING = "string"
wenzelm@29184
   148
  val ALTSTRING = "altstring"
wenzelm@29184
   149
  val VERBATIM = "verbatim"
wenzelm@29184
   150
  val COMMENT = "comment"
wenzelm@29184
   151
  val CONTROL = "control"
wenzelm@29184
   152
wenzelm@29185
   153
  val COMMAND_SPAN = "command_span"
wenzelm@29185
   154
  val IGNORED_SPAN = "ignored_span"
wenzelm@29185
   155
  val MALFORMED_SPAN = "malformed_span"
wenzelm@29185
   156
wenzelm@29184
   157
wenzelm@45674
   158
  /* timing */
wenzelm@45674
   159
wenzelm@45674
   160
  val TIMING = "timing"
wenzelm@45674
   161
  val ELAPSED = "elapsed"
wenzelm@45674
   162
  val CPU = "cpu"
wenzelm@45674
   163
  val GC = "gc"
wenzelm@45674
   164
wenzelm@45674
   165
  object Timing
wenzelm@45674
   166
  {
wenzelm@45674
   167
    def apply(timing: isabelle.Timing): Markup =
wenzelm@45674
   168
      Markup(TIMING, List(
wenzelm@45674
   169
        (ELAPSED, Properties.Value.Double(timing.elapsed.seconds)),
wenzelm@45674
   170
        (CPU, Properties.Value.Double(timing.cpu.seconds)),
wenzelm@45674
   171
        (GC, Properties.Value.Double(timing.gc.seconds))))
wenzelm@45674
   172
    def unapply(markup: Markup): Option[isabelle.Timing] =
wenzelm@45674
   173
      markup match {
wenzelm@45674
   174
        case Markup(TIMING, List(
wenzelm@45674
   175
          (ELAPSED, Properties.Value.Double(elapsed)),
wenzelm@45674
   176
          (CPU, Properties.Value.Double(cpu)),
wenzelm@45674
   177
          (GC, Properties.Value.Double(gc)))) =>
wenzelm@45674
   178
            Some(new isabelle.Timing(Time.seconds(elapsed), Time.seconds(cpu), Time.seconds(gc)))
wenzelm@45674
   179
        case _ => None
wenzelm@45674
   180
      }
wenzelm@45674
   181
  }
wenzelm@45674
   182
wenzelm@45674
   183
wenzelm@29184
   184
  /* toplevel */
wenzelm@29184
   185
wenzelm@38721
   186
  val SUBGOALS = "subgoals"
wenzelm@38721
   187
  val PROOF_STATE = "proof_state"
wenzelm@38721
   188
wenzelm@29184
   189
  val STATE = "state"
wenzelm@29184
   190
  val SUBGOAL = "subgoal"
wenzelm@29184
   191
  val SENDBACK = "sendback"
wenzelm@29184
   192
  val HILITE = "hilite"
wenzelm@29184
   193
wenzelm@29184
   194
wenzelm@29184
   195
  /* command status */
wenzelm@29184
   196
wenzelm@29417
   197
  val TASK = "task"
wenzelm@29417
   198
wenzelm@47395
   199
  val ACCEPTED = "accepted"
wenzelm@37186
   200
  val FORKED = "forked"
wenzelm@37186
   201
  val JOINED = "joined"
wenzelm@29184
   202
  val FAILED = "failed"
wenzelm@29184
   203
  val FINISHED = "finished"
wenzelm@29488
   204
wenzelm@29488
   205
wenzelm@29488
   206
  /* interactive documents */
wenzelm@29488
   207
wenzelm@38414
   208
  val VERSION = "version"
wenzelm@38414
   209
  val ASSIGN = "assign"
wenzelm@29184
   210
wenzelm@27970
   211
wenzelm@43721
   212
  /* prover process */
wenzelm@43721
   213
wenzelm@43721
   214
  val PROVER_COMMAND = "prover_command"
wenzelm@43721
   215
  val PROVER_ARG = "prover_arg"
wenzelm@43721
   216
wenzelm@43721
   217
wenzelm@27970
   218
  /* messages */
wenzelm@27970
   219
wenzelm@43780
   220
  val Serial = new Properties.Long("serial")
wenzelm@27970
   221
wenzelm@29195
   222
  val MESSAGE = "message"
wenzelm@29522
   223
wenzelm@29522
   224
  val INIT = "init"
wenzelm@29522
   225
  val STATUS = "status"
wenzelm@39525
   226
  val REPORT = "report"
wenzelm@29522
   227
  val WRITELN = "writeln"
wenzelm@29522
   228
  val TRACING = "tracing"
wenzelm@29522
   229
  val WARNING = "warning"
wenzelm@29522
   230
  val ERROR = "error"
wenzelm@46774
   231
  val PROTOCOL = "protocol"
wenzelm@29522
   232
  val SYSTEM = "system"
wenzelm@29522
   233
  val STDOUT = "stdout"
wenzelm@45633
   234
  val STDERR = "stderr"
wenzelm@29522
   235
  val EXIT = "exit"
wenzelm@29195
   236
wenzelm@48016
   237
  val Return_Code = new Properties.Int("return_code")
wenzelm@48016
   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@44661
   251
  val Assign_Execs: Properties.T = List((FUNCTION, "assign_execs"))
wenzelm@44676
   252
  val Removed_Versions: Properties.T = List((FUNCTION, "removed_versions"))
wenzelm@44661
   253
wenzelm@43748
   254
  object Invoke_Scala
wenzelm@43748
   255
  {
wenzelm@43780
   256
    def unapply(props: Properties.T): Option[(String, String)] =
wenzelm@43748
   257
      props match {
wenzelm@46122
   258
        case List((FUNCTION, "invoke_scala"), (Markup.NAME, name), (ID, id)) => Some((name, id))
wenzelm@43748
   259
        case _ => None
wenzelm@43748
   260
      }
wenzelm@43748
   261
  }
wenzelm@44298
   262
  object Cancel_Scala
wenzelm@44298
   263
  {
wenzelm@44298
   264
    def unapply(props: Properties.T): Option[String] =
wenzelm@44298
   265
      props match {
wenzelm@46122
   266
        case List((FUNCTION, "cancel_scala"), (ID, id)) => Some(id)
wenzelm@44298
   267
        case _ => None
wenzelm@44298
   268
      }
wenzelm@44298
   269
  }
wenzelm@27958
   270
}
wenzelm@38230
   271