src/Pure/PIDE/markup.scala
author wenzelm
Sat Aug 17 22:15:45 2013 +0200 (2013-08-17)
changeset 53055 0fe8a9972eda
parent 52877 9a26ec5739dd
child 53378 07990ba8c0ea
permissions -rw-r--r--
some protocol to determine provers according to ML;
wenzelm@45670
     1
/*  Title:      Pure/PIDE/markup.scala
wenzelm@45673
     2
    Module:     PIDE
wenzelm@27958
     3
    Author:     Makarius
wenzelm@27958
     4
wenzelm@50201
     5
Isabelle-specific implementation of quasi-abstract markup elements.
wenzelm@27958
     6
*/
wenzelm@27958
     7
wenzelm@27958
     8
package isabelle
wenzelm@27958
     9
wenzelm@27970
    10
wenzelm@32450
    11
object Markup
wenzelm@32450
    12
{
wenzelm@45666
    13
  /* properties */
wenzelm@29184
    14
wenzelm@29184
    15
  val NAME = "name"
wenzelm@43780
    16
  val Name = new Properties.String(NAME)
wenzelm@42136
    17
wenzelm@29184
    18
  val KIND = "kind"
wenzelm@43780
    19
  val Kind = new Properties.String(KIND)
wenzelm@29184
    20
wenzelm@52854
    21
  val INSTANCE = "instance"
wenzelm@52854
    22
  val Instance = new Properties.String(INSTANCE)
wenzelm@52854
    23
wenzelm@29184
    24
wenzelm@50201
    25
  /* basic markup */
wenzelm@29184
    26
wenzelm@45666
    27
  val Empty = Markup("", Nil)
wenzelm@45666
    28
  val Broken = Markup("broken", Nil)
wenzelm@50201
    29
wenzelm@50201
    30
wenzelm@50201
    31
  /* formal entities */
wenzelm@50201
    32
wenzelm@50201
    33
  val BINDING = "binding"
wenzelm@50201
    34
  val ENTITY = "entity"
wenzelm@50201
    35
  val DEF = "def"
wenzelm@50201
    36
  val REF = "ref"
wenzelm@50201
    37
wenzelm@50201
    38
  object Entity
wenzelm@50201
    39
  {
wenzelm@50201
    40
    def unapply(markup: Markup): Option[(String, String)] =
wenzelm@50201
    41
      markup match {
wenzelm@50201
    42
        case Markup(ENTITY, props @ Kind(kind)) =>
wenzelm@50201
    43
          props match {
wenzelm@50201
    44
            case Name(name) => Some(kind, name)
wenzelm@50201
    45
            case _ => None
wenzelm@50201
    46
          }
wenzelm@50201
    47
        case _ => None
wenzelm@50201
    48
      }
wenzelm@50201
    49
  }
wenzelm@50201
    50
wenzelm@50201
    51
wenzelm@50201
    52
  /* position */
wenzelm@50201
    53
wenzelm@50201
    54
  val LINE = "line"
wenzelm@50201
    55
  val OFFSET = "offset"
wenzelm@50201
    56
  val END_OFFSET = "end_offset"
wenzelm@50201
    57
  val FILE = "file"
wenzelm@50201
    58
  val ID = "id"
wenzelm@50201
    59
wenzelm@50201
    60
  val DEF_LINE = "def_line"
wenzelm@50201
    61
  val DEF_OFFSET = "def_offset"
wenzelm@50201
    62
  val DEF_END_OFFSET = "def_end_offset"
wenzelm@50201
    63
  val DEF_FILE = "def_file"
wenzelm@50201
    64
  val DEF_ID = "def_id"
wenzelm@50201
    65
wenzelm@50201
    66
  val POSITION_PROPERTIES = Set(LINE, OFFSET, END_OFFSET, FILE, ID)
wenzelm@50201
    67
  val POSITION = "position"
wenzelm@50201
    68
wenzelm@50201
    69
wenzelm@50201
    70
  /* path */
wenzelm@50201
    71
wenzelm@50201
    72
  val PATH = "path"
wenzelm@50201
    73
wenzelm@50201
    74
  object Path
wenzelm@50201
    75
  {
wenzelm@50201
    76
    def unapply(markup: Markup): Option[String] =
wenzelm@50201
    77
      markup match {
wenzelm@50201
    78
        case Markup(PATH, Name(name)) => Some(name)
wenzelm@50201
    79
        case _ => None
wenzelm@50201
    80
      }
wenzelm@50201
    81
  }
wenzelm@50201
    82
wenzelm@50201
    83
wenzelm@50201
    84
  /* pretty printing */
wenzelm@50201
    85
wenzelm@50201
    86
  val Indent = new Properties.Int("indent")
wenzelm@50201
    87
  val BLOCK = "block"
wenzelm@51570
    88
wenzelm@50201
    89
  val Width = new Properties.Int("width")
wenzelm@50201
    90
  val BREAK = "break"
wenzelm@50201
    91
wenzelm@51570
    92
  val ITEM = "item"
wenzelm@51574
    93
  val BULLET = "bullet"
wenzelm@51570
    94
wenzelm@50201
    95
  val SEPARATOR = "separator"
wenzelm@50201
    96
wenzelm@50201
    97
wenzelm@50201
    98
  /* hidden text */
wenzelm@50201
    99
wenzelm@50201
   100
  val HIDDEN = "hidden"
wenzelm@50201
   101
wenzelm@50201
   102
wenzelm@50201
   103
  /* logical entities */
wenzelm@50201
   104
wenzelm@50201
   105
  val CLASS = "class"
wenzelm@50201
   106
  val TYPE_NAME = "type_name"
wenzelm@50201
   107
  val FIXED = "fixed"
wenzelm@50201
   108
  val CONSTANT = "constant"
wenzelm@50201
   109
wenzelm@50201
   110
  val DYNAMIC_FACT = "dynamic_fact"
wenzelm@50201
   111
wenzelm@50201
   112
wenzelm@50201
   113
  /* inner syntax */
wenzelm@50201
   114
wenzelm@50201
   115
  val TFREE = "tfree"
wenzelm@50201
   116
  val TVAR = "tvar"
wenzelm@50201
   117
  val FREE = "free"
wenzelm@50201
   118
  val SKOLEM = "skolem"
wenzelm@50201
   119
  val BOUND = "bound"
wenzelm@50201
   120
  val VAR = "var"
wenzelm@50201
   121
  val NUMERAL = "numeral"
wenzelm@50201
   122
  val LITERAL = "literal"
wenzelm@50201
   123
  val DELIMITER = "delimiter"
wenzelm@50201
   124
  val INNER_STRING = "inner_string"
wenzelm@50201
   125
  val INNER_COMMENT = "inner_comment"
wenzelm@50201
   126
wenzelm@50201
   127
  val TOKEN_RANGE = "token_range"
wenzelm@50201
   128
wenzelm@50201
   129
  val SORT = "sort"
wenzelm@50201
   130
  val TYP = "typ"
wenzelm@50201
   131
  val TERM = "term"
wenzelm@50201
   132
  val PROP = "prop"
wenzelm@50201
   133
wenzelm@50201
   134
  val SORTING = "sorting"
wenzelm@50201
   135
  val TYPING = "typing"
wenzelm@50201
   136
wenzelm@50201
   137
  val ATTRIBUTE = "attribute"
wenzelm@50201
   138
  val METHOD = "method"
wenzelm@50201
   139
wenzelm@50201
   140
wenzelm@50201
   141
  /* embedded source text */
wenzelm@50201
   142
wenzelm@50201
   143
  val ML_SOURCE = "ML_source"
wenzelm@50201
   144
  val DOCUMENT_SOURCE = "document_source"
wenzelm@50201
   145
wenzelm@50201
   146
  val ANTIQ = "antiq"
wenzelm@50201
   147
  val ML_ANTIQUOTATION = "ML_antiquotation"
wenzelm@50201
   148
  val DOCUMENT_ANTIQUOTATION = "document_antiquotation"
wenzelm@50201
   149
  val DOCUMENT_ANTIQUOTATION_OPTION = "document_antiquotation_option"
wenzelm@50201
   150
wenzelm@50201
   151
wenzelm@50201
   152
  /* text structure */
wenzelm@50201
   153
wenzelm@50201
   154
  val PARAGRAPH = "paragraph"
wenzelm@50545
   155
  val TEXT_FOLD = "text_fold"
wenzelm@50201
   156
wenzelm@50201
   157
wenzelm@50201
   158
  /* ML syntax */
wenzelm@50201
   159
wenzelm@50201
   160
  val ML_KEYWORD = "ML_keyword"
wenzelm@50201
   161
  val ML_DELIMITER = "ML_delimiter"
wenzelm@50201
   162
  val ML_TVAR = "ML_tvar"
wenzelm@50201
   163
  val ML_NUMERAL = "ML_numeral"
wenzelm@50201
   164
  val ML_CHAR = "ML_char"
wenzelm@50201
   165
  val ML_STRING = "ML_string"
wenzelm@50201
   166
  val ML_COMMENT = "ML_comment"
wenzelm@50201
   167
wenzelm@50201
   168
  val ML_DEF = "ML_def"
wenzelm@50201
   169
  val ML_OPEN = "ML_open"
wenzelm@50201
   170
  val ML_STRUCT = "ML_struct"
wenzelm@50201
   171
  val ML_TYPING = "ML_typing"
wenzelm@50201
   172
wenzelm@50201
   173
wenzelm@50201
   174
  /* outer syntax */
wenzelm@50201
   175
wenzelm@50201
   176
  val KEYWORD = "keyword"
wenzelm@50201
   177
  val OPERATOR = "operator"
wenzelm@50201
   178
  val COMMAND = "command"
wenzelm@50201
   179
  val STRING = "string"
wenzelm@50201
   180
  val ALTSTRING = "altstring"
wenzelm@50201
   181
  val VERBATIM = "verbatim"
wenzelm@50201
   182
  val COMMENT = "comment"
wenzelm@50201
   183
  val CONTROL = "control"
wenzelm@50201
   184
wenzelm@50201
   185
  val KEYWORD1 = "keyword1"
wenzelm@50201
   186
  val KEYWORD2 = "keyword2"
wenzelm@50201
   187
wenzelm@50201
   188
wenzelm@50201
   189
  /* timing */
wenzelm@50201
   190
wenzelm@50781
   191
  val Elapsed = new Properties.Double("elapsed")
wenzelm@50781
   192
  val CPU = new Properties.Double("cpu")
wenzelm@50781
   193
  val GC = new Properties.Double("gc")
wenzelm@50781
   194
wenzelm@50781
   195
  object Timing_Properties
wenzelm@50781
   196
  {
wenzelm@50781
   197
    def apply(timing: isabelle.Timing): Properties.T =
wenzelm@50781
   198
      Elapsed(timing.elapsed.seconds) ::: CPU(timing.cpu.seconds) ::: GC(timing.gc.seconds)
wenzelm@51662
   199
wenzelm@50781
   200
    def unapply(props: Properties.T): Option[isabelle.Timing] =
wenzelm@50781
   201
      (props, props, props) match {
wenzelm@50781
   202
        case (Elapsed(elapsed), CPU(cpu), GC(gc)) =>
wenzelm@50781
   203
          Some(new isabelle.Timing(Time.seconds(elapsed), Time.seconds(cpu), Time.seconds(gc)))
wenzelm@50781
   204
        case _ => None
wenzelm@50781
   205
      }
wenzelm@50781
   206
  }
wenzelm@50781
   207
wenzelm@50201
   208
  val TIMING = "timing"
wenzelm@50201
   209
wenzelm@50201
   210
  object Timing
wenzelm@50201
   211
  {
wenzelm@50781
   212
    def apply(timing: isabelle.Timing): Markup = Markup(TIMING, Timing_Properties(timing))
wenzelm@51662
   213
wenzelm@50201
   214
    def unapply(markup: Markup): Option[isabelle.Timing] =
wenzelm@50201
   215
      markup match {
wenzelm@50781
   216
        case Markup(TIMING, Timing_Properties(timing)) => Some(timing)
wenzelm@50201
   217
        case _ => None
wenzelm@50201
   218
      }
wenzelm@50201
   219
  }
wenzelm@50201
   220
wenzelm@50201
   221
wenzelm@51662
   222
  /* command timing */
wenzelm@51662
   223
wenzelm@51818
   224
  val COMMAND_TIMING = "command_timing"
wenzelm@51662
   225
wenzelm@51662
   226
wenzelm@50201
   227
  /* toplevel */
wenzelm@50201
   228
wenzelm@50201
   229
  val SUBGOALS = "subgoals"
wenzelm@50201
   230
  val PROOF_STATE = "proof_state"
wenzelm@50201
   231
wenzelm@50201
   232
  val STATE = "state"
wenzelm@50543
   233
  val GOAL = "goal"
wenzelm@50201
   234
  val SUBGOAL = "subgoal"
wenzelm@50215
   235
wenzelm@50450
   236
wenzelm@50201
   237
  /* command status */
wenzelm@50201
   238
wenzelm@50201
   239
  val TASK = "task"
wenzelm@50201
   240
wenzelm@50201
   241
  val ACCEPTED = "accepted"
wenzelm@50201
   242
  val FORKED = "forked"
wenzelm@50201
   243
  val JOINED = "joined"
wenzelm@50201
   244
  val RUNNING = "running"
wenzelm@50201
   245
  val FINISHED = "finished"
wenzelm@50201
   246
  val FAILED = "failed"
wenzelm@50201
   247
wenzelm@50201
   248
wenzelm@50201
   249
  /* interactive documents */
wenzelm@50201
   250
wenzelm@50201
   251
  val VERSION = "version"
wenzelm@50201
   252
  val ASSIGN = "assign"
wenzelm@50201
   253
wenzelm@50201
   254
wenzelm@50201
   255
  /* prover process */
wenzelm@50201
   256
wenzelm@50201
   257
  val PROVER_COMMAND = "prover_command"
wenzelm@50201
   258
  val PROVER_ARG = "prover_arg"
wenzelm@50201
   259
wenzelm@50201
   260
wenzelm@50201
   261
  /* messages */
wenzelm@50201
   262
wenzelm@50201
   263
  val Serial = new Properties.Long("serial")
wenzelm@50201
   264
wenzelm@50201
   265
  val MESSAGE = "message"
wenzelm@50201
   266
wenzelm@50201
   267
  val INIT = "init"
wenzelm@50201
   268
  val STATUS = "status"
wenzelm@50201
   269
  val REPORT = "report"
wenzelm@50500
   270
  val RESULT = "result"
wenzelm@50201
   271
  val WRITELN = "writeln"
wenzelm@50201
   272
  val TRACING = "tracing"
wenzelm@50201
   273
  val WARNING = "warning"
wenzelm@50201
   274
  val ERROR = "error"
wenzelm@50201
   275
  val PROTOCOL = "protocol"
wenzelm@50201
   276
  val SYSTEM = "system"
wenzelm@50201
   277
  val STDOUT = "stdout"
wenzelm@50201
   278
  val STDERR = "stderr"
wenzelm@50201
   279
  val EXIT = "exit"
wenzelm@50201
   280
wenzelm@50201
   281
  val WRITELN_MESSAGE = "writeln_message"
wenzelm@50201
   282
  val TRACING_MESSAGE = "tracing_message"
wenzelm@50201
   283
  val WARNING_MESSAGE = "warning_message"
wenzelm@50201
   284
  val ERROR_MESSAGE = "error_message"
wenzelm@50201
   285
wenzelm@52876
   286
  val messages =
wenzelm@50201
   287
    Map(WRITELN -> WRITELN_MESSAGE, TRACING -> TRACING_MESSAGE,
wenzelm@52876
   288
        WARNING -> WARNING_MESSAGE, ERROR -> ERROR_MESSAGE)
wenzelm@52876
   289
  val message: String => String = messages.withDefault((s: String) => s)
wenzelm@50201
   290
wenzelm@50201
   291
  val Return_Code = new Properties.Int("return_code")
wenzelm@50201
   292
wenzelm@50201
   293
  val LEGACY = "legacy"
wenzelm@50201
   294
wenzelm@50201
   295
  val NO_REPORT = "no_report"
wenzelm@50201
   296
wenzelm@50201
   297
  val BAD = "bad"
wenzelm@50201
   298
wenzelm@50500
   299
  val INTENSIFY = "intensify"
wenzelm@52643
   300
  val INFORMATION = "information"
wenzelm@50500
   301
wenzelm@50500
   302
wenzelm@50500
   303
  /* active areas */
wenzelm@50500
   304
wenzelm@50715
   305
  val BROWSER = "browser"
wenzelm@50500
   306
  val GRAPHVIEW = "graphview"
wenzelm@50500
   307
wenzelm@50500
   308
  val SENDBACK = "sendback"
wenzelm@50500
   309
  val PADDING = "padding"
wenzelm@52697
   310
  val PADDING_LINE = (PADDING, "line")
wenzelm@52697
   311
  val PADDING_COMMAND = (PADDING, "command")
wenzelm@50500
   312
wenzelm@50500
   313
  val DIALOG = "dialog"
wenzelm@50503
   314
  val Result = new Properties.String(RESULT)
wenzelm@50500
   315
wenzelm@50201
   316
wenzelm@50201
   317
  /* protocol message functions */
wenzelm@50201
   318
wenzelm@50201
   319
  val FUNCTION = "function"
wenzelm@50201
   320
  val Function = new Properties.String(FUNCTION)
wenzelm@50201
   321
wenzelm@52800
   322
  val Flush: Properties.T = List((FUNCTION, "flush"))
wenzelm@52800
   323
wenzelm@52563
   324
  val Assign_Update: Properties.T = List((FUNCTION, "assign_update"))
wenzelm@50201
   325
  val Removed_Versions: Properties.T = List((FUNCTION, "removed_versions"))
wenzelm@50201
   326
wenzelm@52111
   327
  object Protocol_Handler
wenzelm@52111
   328
  {
wenzelm@52111
   329
    def unapply(props: Properties.T): Option[(String)] =
wenzelm@52111
   330
      props match {
wenzelm@52111
   331
        case List((FUNCTION, "protocol_handler"), (NAME, name)) => Some(name)
wenzelm@52111
   332
        case _ => None
wenzelm@52111
   333
      }
wenzelm@52111
   334
  }
wenzelm@52111
   335
wenzelm@52111
   336
  val INVOKE_SCALA = "invoke_scala"
wenzelm@50201
   337
  object Invoke_Scala
wenzelm@50201
   338
  {
wenzelm@50201
   339
    def unapply(props: Properties.T): Option[(String, String)] =
wenzelm@50201
   340
      props match {
wenzelm@52111
   341
        case List((FUNCTION, INVOKE_SCALA), (NAME, name), (ID, id)) => Some((name, id))
wenzelm@50201
   342
        case _ => None
wenzelm@50201
   343
      }
wenzelm@50201
   344
  }
wenzelm@52111
   345
wenzelm@52111
   346
  val CANCEL_SCALA = "cancel_scala"
wenzelm@50201
   347
  object Cancel_Scala
wenzelm@50201
   348
  {
wenzelm@50201
   349
    def unapply(props: Properties.T): Option[String] =
wenzelm@50201
   350
      props match {
wenzelm@52111
   351
        case List((FUNCTION, CANCEL_SCALA), (ID, id)) => Some(id)
wenzelm@50201
   352
        case _ => None
wenzelm@50201
   353
      }
wenzelm@50201
   354
  }
wenzelm@50255
   355
wenzelm@53055
   356
  val SLEDGEHAMMER_PROVERS = "sledgehammer_provers"
wenzelm@53055
   357
  val Sledgehammer_Provers: Properties.T = List((FUNCTION, SLEDGEHAMMER_PROVERS))
wenzelm@53055
   358
wenzelm@50255
   359
  object ML_Statistics
wenzelm@50255
   360
  {
wenzelm@50255
   361
    def unapply(props: Properties.T): Option[Properties.T] =
wenzelm@50255
   362
      props match {
wenzelm@50255
   363
        case (FUNCTION, "ML_statistics") :: stats => Some(stats)
wenzelm@50255
   364
        case _ => None
wenzelm@50255
   365
      }
wenzelm@50255
   366
  }
wenzelm@50975
   367
wenzelm@50975
   368
  object Task_Statistics
wenzelm@50975
   369
  {
wenzelm@50975
   370
    def unapply(props: Properties.T): Option[Properties.T] =
wenzelm@50975
   371
      props match {
wenzelm@50975
   372
        case (FUNCTION, "task_statistics") :: stats => Some(stats)
wenzelm@50975
   373
        case _ => None
wenzelm@50975
   374
      }
wenzelm@50975
   375
  }
wenzelm@45666
   376
}
wenzelm@43721
   377
wenzelm@43721
   378
wenzelm@45666
   379
sealed case class Markup(name: String, properties: Properties.T)
wenzelm@43748
   380