src/Pure/General/markup.scala
author wenzelm
Sun Sep 19 17:12:34 2010 +0200 (2010-09-19 ago)
changeset 39525 72e949a0425b
parent 39513 fce2202892c4
child 39585 00be8711082f
permissions -rw-r--r--
simplified Isabelle_Process message kinds;
misc tuning and simplification;
wenzelm@27958
     1
/*  Title:      Pure/General/markup.scala
wenzelm@27958
     2
    Author:     Makarius
wenzelm@27958
     3
wenzelm@27958
     4
Common markup elements.
wenzelm@27958
     5
*/
wenzelm@27958
     6
wenzelm@27958
     7
package isabelle
wenzelm@27958
     8
wenzelm@27970
     9
wenzelm@32450
    10
object Markup
wenzelm@32450
    11
{
wenzelm@38722
    12
  /* plain values */
wenzelm@38414
    13
wenzelm@38414
    14
  object Int {
wenzelm@38414
    15
    def apply(i: scala.Int): String = i.toString
wenzelm@38414
    16
    def unapply(s: String): Option[scala.Int] =
wenzelm@38414
    17
      try { Some(Integer.parseInt(s)) }
wenzelm@38414
    18
      catch { case _: NumberFormatException => None }
wenzelm@38414
    19
  }
wenzelm@38414
    20
wenzelm@38414
    21
  object Long {
wenzelm@38414
    22
    def apply(i: scala.Long): String = i.toString
wenzelm@38414
    23
    def unapply(s: String): Option[scala.Long] =
wenzelm@38414
    24
      try { Some(java.lang.Long.parseLong(s)) }
wenzelm@38414
    25
      catch { case _: NumberFormatException => None }
wenzelm@38414
    26
  }
wenzelm@38414
    27
wenzelm@38414
    28
wenzelm@38722
    29
  /* named properties */
wenzelm@36683
    30
wenzelm@38722
    31
  class Property(val name: String)
wenzelm@38355
    32
  {
wenzelm@38722
    33
    def apply(value: String): List[(String, String)] = List((name, value))
wenzelm@38722
    34
    def unapply(props: List[(String, String)]): Option[String] =
wenzelm@38722
    35
      props.find(_._1 == name).map(_._2)
wenzelm@38355
    36
  }
wenzelm@38355
    37
wenzelm@38722
    38
  class Int_Property(name: String)
wenzelm@36683
    39
  {
wenzelm@38722
    40
    def apply(value: scala.Int): List[(String, String)] = List((name, Int(value)))
wenzelm@38722
    41
    def unapply(props: List[(String, String)]): Option[Int] =
wenzelm@38722
    42
      props.find(_._1 == name) match {
wenzelm@38722
    43
        case None => None
wenzelm@38722
    44
        case Some((_, value)) => Int.unapply(value)
wenzelm@38722
    45
      }
wenzelm@38722
    46
  }
wenzelm@38722
    47
wenzelm@38722
    48
  class Long_Property(name: String)
wenzelm@38722
    49
  {
wenzelm@38722
    50
    def apply(value: scala.Long): List[(String, String)] = List((name, Long(value)))
wenzelm@38722
    51
    def unapply(props: List[(String, String)]): Option[Long] =
wenzelm@38722
    52
      props.find(_._1 == name) match {
wenzelm@38722
    53
        case None => None
wenzelm@38722
    54
        case Some((_, value)) => Long.unapply(value)
wenzelm@38722
    55
      }
wenzelm@36683
    56
  }
wenzelm@36683
    57
wenzelm@36683
    58
wenzelm@38474
    59
  /* empty */
wenzelm@38474
    60
wenzelm@38474
    61
  val Empty = Markup("", Nil)
wenzelm@38474
    62
wenzelm@38474
    63
wenzelm@38721
    64
  /* misc properties */
wenzelm@29184
    65
wenzelm@29184
    66
  val NAME = "name"
wenzelm@29184
    67
  val KIND = "kind"
wenzelm@29184
    68
wenzelm@29184
    69
wenzelm@33088
    70
  /* formal entities */
wenzelm@33088
    71
wenzelm@38887
    72
  val BINDING = "binding"
wenzelm@33088
    73
  val ENTITY = "entity"
wenzelm@33088
    74
  val DEF = "def"
wenzelm@33088
    75
  val REF = "ref"
wenzelm@33088
    76
wenzelm@33088
    77
wenzelm@27970
    78
  /* position */
wenzelm@27970
    79
wenzelm@27970
    80
  val LINE = "line"
wenzelm@27970
    81
  val COLUMN = "column"
wenzelm@27970
    82
  val OFFSET = "offset"
wenzelm@27970
    83
  val END_LINE = "end_line"
wenzelm@27970
    84
  val END_COLUMN = "end_column"
wenzelm@27970
    85
  val END_OFFSET = "end_offset"
wenzelm@27970
    86
  val FILE = "file"
wenzelm@27970
    87
  val ID = "id"
wenzelm@27970
    88
wenzelm@32450
    89
  val POSITION_PROPERTIES =
wenzelm@32450
    90
    Set(LINE, COLUMN, OFFSET, END_LINE, END_COLUMN, END_OFFSET, FILE, ID)
wenzelm@29205
    91
wenzelm@29184
    92
  val POSITION = "position"
wenzelm@29184
    93
wenzelm@29184
    94
wenzelm@36683
    95
  /* pretty printing */
wenzelm@36683
    96
wenzelm@38724
    97
  val Indent = new Int_Property("indent")
wenzelm@36683
    98
  val BLOCK = "block"
wenzelm@38724
    99
  val Width = new Int_Property("width")
wenzelm@36683
   100
  val BREAK = "break"
wenzelm@36683
   101
wenzelm@36683
   102
wenzelm@33985
   103
  /* hidden text */
wenzelm@33985
   104
wenzelm@33985
   105
  val HIDDEN = "hidden"
wenzelm@33985
   106
wenzelm@33985
   107
wenzelm@29184
   108
  /* logical entities */
wenzelm@29184
   109
wenzelm@29184
   110
  val TCLASS = "tclass"
wenzelm@29184
   111
  val TYCON = "tycon"
wenzelm@29184
   112
  val FIXED_DECL = "fixed_decl"
wenzelm@29184
   113
  val FIXED = "fixed"
wenzelm@29184
   114
  val CONST_DECL = "const_decl"
wenzelm@29184
   115
  val CONST = "const"
wenzelm@29184
   116
  val FACT_DECL = "fact_decl"
wenzelm@29184
   117
  val FACT = "fact"
wenzelm@29184
   118
  val DYNAMIC_FACT = "dynamic_fact"
wenzelm@29184
   119
  val LOCAL_FACT_DECL = "local_fact_decl"
wenzelm@29184
   120
  val LOCAL_FACT = "local_fact"
wenzelm@29184
   121
wenzelm@29184
   122
wenzelm@29184
   123
  /* inner syntax */
wenzelm@29184
   124
wenzelm@29184
   125
  val TFREE = "tfree"
wenzelm@29184
   126
  val TVAR = "tvar"
wenzelm@29184
   127
  val FREE = "free"
wenzelm@29184
   128
  val SKOLEM = "skolem"
wenzelm@29184
   129
  val BOUND = "bound"
wenzelm@29184
   130
  val VAR = "var"
wenzelm@29184
   131
  val NUM = "num"
wenzelm@29184
   132
  val FLOAT = "float"
wenzelm@29184
   133
  val XNUM = "xnum"
wenzelm@29184
   134
  val XSTR = "xstr"
wenzelm@29184
   135
  val LITERAL = "literal"
wenzelm@29184
   136
  val INNER_COMMENT = "inner_comment"
wenzelm@29184
   137
wenzelm@39168
   138
  val TOKEN_RANGE = "token_range"
wenzelm@39168
   139
wenzelm@29184
   140
  val SORT = "sort"
wenzelm@29184
   141
  val TYP = "typ"
wenzelm@29184
   142
  val TERM = "term"
wenzelm@29184
   143
  val PROP = "prop"
wenzelm@29184
   144
wenzelm@29184
   145
  val ATTRIBUTE = "attribute"
wenzelm@29184
   146
  val METHOD = "method"
wenzelm@29184
   147
wenzelm@29184
   148
wenzelm@29184
   149
  /* embedded source text */
wenzelm@29184
   150
wenzelm@29184
   151
  val ML_SOURCE = "ML_source"
wenzelm@29184
   152
  val DOC_SOURCE = "doc_source"
wenzelm@29184
   153
wenzelm@29184
   154
  val ANTIQ = "antiq"
wenzelm@29184
   155
  val ML_ANTIQ = "ML_antiq"
wenzelm@29184
   156
  val DOC_ANTIQ = "doc_antiq"
wenzelm@29184
   157
wenzelm@29184
   158
wenzelm@30615
   159
  /* ML syntax */
wenzelm@30615
   160
wenzelm@30615
   161
  val ML_KEYWORD = "ML_keyword"
wenzelm@37195
   162
  val ML_DELIMITER = "ML_delimiter"
wenzelm@30615
   163
  val ML_IDENT = "ML_ident"
wenzelm@30615
   164
  val ML_TVAR = "ML_tvar"
wenzelm@30615
   165
  val ML_NUMERAL = "ML_numeral"
wenzelm@30615
   166
  val ML_CHAR = "ML_char"
wenzelm@30615
   167
  val ML_STRING = "ML_string"
wenzelm@30615
   168
  val ML_COMMENT = "ML_comment"
wenzelm@30615
   169
  val ML_MALFORMED = "ML_malformed"
wenzelm@30615
   170
wenzelm@30702
   171
  val ML_DEF = "ML_def"
wenzelm@31472
   172
  val ML_OPEN = "ML_open"
wenzelm@31472
   173
  val ML_STRUCT = "ML_struct"
wenzelm@30702
   174
  val ML_REF = "ML_ref"
wenzelm@30702
   175
  val ML_TYPING = "ML_typing"
wenzelm@30702
   176
wenzelm@30615
   177
wenzelm@29184
   178
  /* outer syntax */
wenzelm@29184
   179
wenzelm@29184
   180
  val KEYWORD_DECL = "keyword_decl"
wenzelm@29184
   181
  val COMMAND_DECL = "command_decl"
wenzelm@29184
   182
wenzelm@29184
   183
  val KEYWORD = "keyword"
wenzelm@37194
   184
  val OPERATOR = "operator"
wenzelm@29184
   185
  val COMMAND = "command"
wenzelm@29184
   186
  val IDENT = "ident"
wenzelm@29184
   187
  val STRING = "string"
wenzelm@29184
   188
  val ALTSTRING = "altstring"
wenzelm@29184
   189
  val VERBATIM = "verbatim"
wenzelm@29184
   190
  val COMMENT = "comment"
wenzelm@29184
   191
  val CONTROL = "control"
wenzelm@29184
   192
  val MALFORMED = "malformed"
wenzelm@29184
   193
wenzelm@29185
   194
  val COMMAND_SPAN = "command_span"
wenzelm@29185
   195
  val IGNORED_SPAN = "ignored_span"
wenzelm@29185
   196
  val MALFORMED_SPAN = "malformed_span"
wenzelm@29185
   197
wenzelm@29184
   198
wenzelm@29184
   199
  /* toplevel */
wenzelm@29184
   200
wenzelm@38721
   201
  val SUBGOALS = "subgoals"
wenzelm@38721
   202
  val PROOF_STATE = "proof_state"
wenzelm@38721
   203
wenzelm@29184
   204
  val STATE = "state"
wenzelm@29184
   205
  val SUBGOAL = "subgoal"
wenzelm@29184
   206
  val SENDBACK = "sendback"
wenzelm@29184
   207
  val HILITE = "hilite"
wenzelm@29184
   208
wenzelm@29184
   209
wenzelm@29184
   210
  /* command status */
wenzelm@29184
   211
wenzelm@29417
   212
  val TASK = "task"
wenzelm@29417
   213
wenzelm@37186
   214
  val FORKED = "forked"
wenzelm@37186
   215
  val JOINED = "joined"
wenzelm@29184
   216
  val FAILED = "failed"
wenzelm@29184
   217
  val FINISHED = "finished"
wenzelm@29488
   218
wenzelm@29488
   219
wenzelm@29488
   220
  /* interactive documents */
wenzelm@29488
   221
wenzelm@38414
   222
  val VERSION = "version"
wenzelm@38414
   223
  val EXEC = "exec"
wenzelm@38414
   224
  val ASSIGN = "assign"
wenzelm@29488
   225
  val EDIT = "edit"
wenzelm@29184
   226
wenzelm@27970
   227
wenzelm@27970
   228
  /* messages */
wenzelm@27970
   229
wenzelm@27970
   230
  val PID = "pid"
wenzelm@38872
   231
  val Serial = new Long_Property("serial")
wenzelm@27970
   232
wenzelm@29195
   233
  val MESSAGE = "message"
wenzelm@29522
   234
  val CLASS = "class"
wenzelm@29522
   235
wenzelm@29522
   236
  val INIT = "init"
wenzelm@29522
   237
  val STATUS = "status"
wenzelm@39525
   238
  val REPORT = "report"
wenzelm@29522
   239
  val WRITELN = "writeln"
wenzelm@29522
   240
  val TRACING = "tracing"
wenzelm@29522
   241
  val WARNING = "warning"
wenzelm@29522
   242
  val ERROR = "error"
wenzelm@29522
   243
  val SYSTEM = "system"
wenzelm@29522
   244
  val STDOUT = "stdout"
wenzelm@29522
   245
  val EXIT = "exit"
wenzelm@29195
   246
wenzelm@39439
   247
  val NO_REPORT = "no_report"
wenzelm@39439
   248
wenzelm@39171
   249
  val BAD = "bad"
wenzelm@39171
   250
wenzelm@38231
   251
  val Ready = Markup("ready", Nil)
wenzelm@31384
   252
wenzelm@27970
   253
wenzelm@34119
   254
  /* system data */
wenzelm@27970
   255
wenzelm@38231
   256
  val Data = Markup("data", Nil)
wenzelm@27958
   257
}
wenzelm@38230
   258
wenzelm@38230
   259
sealed case class Markup(name: String, properties: List[(String, String)])