src/Pure/PIDE/isabelle_markup.scala
author wenzelm
Thu Sep 20 21:31:56 2012 +0200 (2012-09-20 ago)
changeset 49473 ca7e2c21b104
parent 49418 c451856129cd
child 49554 7b7bd2d7661d
permissions -rw-r--r--
tuned rendering;
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@49473
    72
  val SEPARATOR = "separator"
wenzelm@49473
    73
wenzelm@36683
    74
wenzelm@33985
    75
  /* hidden text */
wenzelm@33985
    76
wenzelm@33985
    77
  val HIDDEN = "hidden"
wenzelm@33985
    78
wenzelm@33985
    79
wenzelm@29184
    80
  /* logical entities */
wenzelm@29184
    81
wenzelm@43551
    82
  val CLASS = "class"
wenzelm@49321
    83
  val TYPE_NAME = "type_name"
wenzelm@29184
    84
  val FIXED = "fixed"
wenzelm@43552
    85
  val CONSTANT = "constant"
wenzelm@43552
    86
wenzelm@29184
    87
  val DYNAMIC_FACT = "dynamic_fact"
wenzelm@29184
    88
wenzelm@29184
    89
wenzelm@29184
    90
  /* inner syntax */
wenzelm@29184
    91
wenzelm@29184
    92
  val TFREE = "tfree"
wenzelm@29184
    93
  val TVAR = "tvar"
wenzelm@29184
    94
  val FREE = "free"
wenzelm@29184
    95
  val SKOLEM = "skolem"
wenzelm@29184
    96
  val BOUND = "bound"
wenzelm@29184
    97
  val VAR = "var"
wenzelm@45702
    98
  val NUMERAL = "numeral"
wenzelm@29184
    99
  val LITERAL = "literal"
wenzelm@43432
   100
  val DELIMITER = "delimiter"
wenzelm@43386
   101
  val INNER_STRING = "inner_string"
wenzelm@29184
   102
  val INNER_COMMENT = "inner_comment"
wenzelm@29184
   103
wenzelm@39168
   104
  val TOKEN_RANGE = "token_range"
wenzelm@39168
   105
wenzelm@29184
   106
  val SORT = "sort"
wenzelm@29184
   107
  val TYP = "typ"
wenzelm@29184
   108
  val TERM = "term"
wenzelm@29184
   109
  val PROP = "prop"
wenzelm@29184
   110
wenzelm@45445
   111
  val TYPING = "typing"
wenzelm@45445
   112
wenzelm@29184
   113
  val ATTRIBUTE = "attribute"
wenzelm@29184
   114
  val METHOD = "method"
wenzelm@29184
   115
wenzelm@29184
   116
wenzelm@29184
   117
  /* embedded source text */
wenzelm@29184
   118
wenzelm@29184
   119
  val ML_SOURCE = "ML_source"
wenzelm@49321
   120
  val DOCUMENT_SOURCE = "document_source"
wenzelm@29184
   121
wenzelm@29184
   122
  val ANTIQ = "antiq"
wenzelm@49321
   123
  val ML_ANTIQUOTATION = "ML_antiquotation"
wenzelm@49321
   124
  val DOCUMENT_ANTIQUOTATION = "document_antiquotation"
wenzelm@49321
   125
  val DOCUMENT_ANTIQUOTATION_OPTION = "document_antiquotation_option"
wenzelm@29184
   126
wenzelm@29184
   127
wenzelm@30615
   128
  /* ML syntax */
wenzelm@30615
   129
wenzelm@30615
   130
  val ML_KEYWORD = "ML_keyword"
wenzelm@37195
   131
  val ML_DELIMITER = "ML_delimiter"
wenzelm@30615
   132
  val ML_TVAR = "ML_tvar"
wenzelm@30615
   133
  val ML_NUMERAL = "ML_numeral"
wenzelm@30615
   134
  val ML_CHAR = "ML_char"
wenzelm@30615
   135
  val ML_STRING = "ML_string"
wenzelm@30615
   136
  val ML_COMMENT = "ML_comment"
wenzelm@30615
   137
wenzelm@30702
   138
  val ML_DEF = "ML_def"
wenzelm@31472
   139
  val ML_OPEN = "ML_open"
wenzelm@31472
   140
  val ML_STRUCT = "ML_struct"
wenzelm@30702
   141
  val ML_TYPING = "ML_typing"
wenzelm@30702
   142
wenzelm@30615
   143
wenzelm@29184
   144
  /* outer syntax */
wenzelm@29184
   145
wenzelm@29184
   146
  val KEYWORD = "keyword"
wenzelm@37194
   147
  val OPERATOR = "operator"
wenzelm@29184
   148
  val COMMAND = "command"
wenzelm@29184
   149
  val STRING = "string"
wenzelm@29184
   150
  val ALTSTRING = "altstring"
wenzelm@29184
   151
  val VERBATIM = "verbatim"
wenzelm@29184
   152
  val COMMENT = "comment"
wenzelm@29184
   153
  val CONTROL = "control"
wenzelm@29184
   154
wenzelm@29184
   155
wenzelm@45674
   156
  /* timing */
wenzelm@45674
   157
wenzelm@45674
   158
  val TIMING = "timing"
wenzelm@45674
   159
  val ELAPSED = "elapsed"
wenzelm@45674
   160
  val CPU = "cpu"
wenzelm@45674
   161
  val GC = "gc"
wenzelm@45674
   162
wenzelm@45674
   163
  object Timing
wenzelm@45674
   164
  {
wenzelm@45674
   165
    def apply(timing: isabelle.Timing): Markup =
wenzelm@45674
   166
      Markup(TIMING, List(
wenzelm@45674
   167
        (ELAPSED, Properties.Value.Double(timing.elapsed.seconds)),
wenzelm@45674
   168
        (CPU, Properties.Value.Double(timing.cpu.seconds)),
wenzelm@45674
   169
        (GC, Properties.Value.Double(timing.gc.seconds))))
wenzelm@45674
   170
    def unapply(markup: Markup): Option[isabelle.Timing] =
wenzelm@45674
   171
      markup match {
wenzelm@45674
   172
        case Markup(TIMING, List(
wenzelm@45674
   173
          (ELAPSED, Properties.Value.Double(elapsed)),
wenzelm@45674
   174
          (CPU, Properties.Value.Double(cpu)),
wenzelm@45674
   175
          (GC, Properties.Value.Double(gc)))) =>
wenzelm@45674
   176
            Some(new isabelle.Timing(Time.seconds(elapsed), Time.seconds(cpu), Time.seconds(gc)))
wenzelm@45674
   177
        case _ => None
wenzelm@45674
   178
      }
wenzelm@45674
   179
  }
wenzelm@45674
   180
wenzelm@45674
   181
wenzelm@29184
   182
  /* toplevel */
wenzelm@29184
   183
wenzelm@38721
   184
  val SUBGOALS = "subgoals"
wenzelm@38721
   185
  val PROOF_STATE = "proof_state"
wenzelm@38721
   186
wenzelm@29184
   187
  val STATE = "state"
wenzelm@29184
   188
  val SUBGOAL = "subgoal"
wenzelm@29184
   189
  val SENDBACK = "sendback"
wenzelm@49358
   190
  val INTENSIFY = "intensify"
wenzelm@29184
   191
wenzelm@29184
   192
wenzelm@29184
   193
  /* command status */
wenzelm@29184
   194
wenzelm@29417
   195
  val TASK = "task"
wenzelm@29417
   196
wenzelm@47395
   197
  val ACCEPTED = "accepted"
wenzelm@37186
   198
  val FORKED = "forked"
wenzelm@37186
   199
  val JOINED = "joined"
wenzelm@49036
   200
  val RUNNING = "running"
wenzelm@49036
   201
  val FINISHED = "finished"
wenzelm@29184
   202
  val FAILED = "failed"
wenzelm@29488
   203
wenzelm@29488
   204
wenzelm@29488
   205
  /* interactive documents */
wenzelm@29488
   206
wenzelm@38414
   207
  val VERSION = "version"
wenzelm@38414
   208
  val ASSIGN = "assign"
wenzelm@29184
   209
wenzelm@27970
   210
wenzelm@43721
   211
  /* prover process */
wenzelm@43721
   212
wenzelm@43721
   213
  val PROVER_COMMAND = "prover_command"
wenzelm@43721
   214
  val PROVER_ARG = "prover_arg"
wenzelm@43721
   215
wenzelm@43721
   216
wenzelm@27970
   217
  /* messages */
wenzelm@27970
   218
wenzelm@43780
   219
  val Serial = new Properties.Long("serial")
wenzelm@27970
   220
wenzelm@29195
   221
  val MESSAGE = "message"
wenzelm@29522
   222
wenzelm@29522
   223
  val INIT = "init"
wenzelm@29522
   224
  val STATUS = "status"
wenzelm@39525
   225
  val REPORT = "report"
wenzelm@29522
   226
  val WRITELN = "writeln"
wenzelm@29522
   227
  val TRACING = "tracing"
wenzelm@29522
   228
  val WARNING = "warning"
wenzelm@29522
   229
  val ERROR = "error"
wenzelm@46774
   230
  val PROTOCOL = "protocol"
wenzelm@29522
   231
  val SYSTEM = "system"
wenzelm@29522
   232
  val STDOUT = "stdout"
wenzelm@45633
   233
  val STDERR = "stderr"
wenzelm@29522
   234
  val EXIT = "exit"
wenzelm@29195
   235
wenzelm@49418
   236
  val WRITELN_MESSAGE = "writeln_message"
wenzelm@49418
   237
  val TRACING_MESSAGE = "tracing_message"
wenzelm@49418
   238
  val WARNING_MESSAGE = "warning_message"
wenzelm@49418
   239
  val ERROR_MESSAGE = "error_message"
wenzelm@49418
   240
wenzelm@49418
   241
  val message: String => String =
wenzelm@49418
   242
    Map(WRITELN -> WRITELN_MESSAGE, TRACING -> TRACING_MESSAGE,
wenzelm@49418
   243
        WARNING -> WARNING_MESSAGE, ERROR -> ERROR_MESSAGE)
wenzelm@49418
   244
      .withDefault((name: String) => name + "_message")
wenzelm@49418
   245
wenzelm@48016
   246
  val Return_Code = new Properties.Int("return_code")
wenzelm@48016
   247
wenzelm@44549
   248
  val LEGACY = "legacy"
wenzelm@44549
   249
wenzelm@39439
   250
  val NO_REPORT = "no_report"
wenzelm@39439
   251
wenzelm@39171
   252
  val BAD = "bad"
wenzelm@39171
   253
wenzelm@27970
   254
wenzelm@46774
   255
  /* protocol message functions */
wenzelm@43748
   256
wenzelm@43748
   257
  val FUNCTION = "function"
wenzelm@43780
   258
  val Function = new Properties.String(FUNCTION)
wenzelm@43748
   259
wenzelm@44661
   260
  val Assign_Execs: Properties.T = List((FUNCTION, "assign_execs"))
wenzelm@44676
   261
  val Removed_Versions: Properties.T = List((FUNCTION, "removed_versions"))
wenzelm@44661
   262
wenzelm@43748
   263
  object Invoke_Scala
wenzelm@43748
   264
  {
wenzelm@43780
   265
    def unapply(props: Properties.T): Option[(String, String)] =
wenzelm@43748
   266
      props match {
wenzelm@46122
   267
        case List((FUNCTION, "invoke_scala"), (Markup.NAME, name), (ID, id)) => Some((name, id))
wenzelm@43748
   268
        case _ => None
wenzelm@43748
   269
      }
wenzelm@43748
   270
  }
wenzelm@44298
   271
  object Cancel_Scala
wenzelm@44298
   272
  {
wenzelm@44298
   273
    def unapply(props: Properties.T): Option[String] =
wenzelm@44298
   274
      props match {
wenzelm@46122
   275
        case List((FUNCTION, "cancel_scala"), (ID, id)) => Some(id)
wenzelm@44298
   276
        case _ => None
wenzelm@44298
   277
      }
wenzelm@44298
   278
  }
wenzelm@27958
   279
}
wenzelm@38230
   280