src/Pure/General/markup.scala
author wenzelm
Wed Aug 11 22:41:26 2010 +0200 (2010-08-11 ago)
changeset 38355 8cb265fb12fe
parent 38259 2b61c5e27399
child 38414 49f1f657adc2
permissions -rw-r--r--
represent document ids by (long) int, to benefit from the somewhat faster Inttab in ML (LinearSet in Scala is invariably indexed by native object ids);
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@36683
    12
  /* property values */
wenzelm@36683
    13
wenzelm@36683
    14
  def get_string(name: String, props: List[(String, String)]): Option[String] =
wenzelm@36683
    15
    props.find(p => p._1 == name).map(_._2)
wenzelm@36683
    16
wenzelm@38355
    17
wenzelm@38355
    18
  def parse_long(s: String): Option[Long] =
wenzelm@38355
    19
    try { Some(java.lang.Long.parseLong(s)) }
wenzelm@38355
    20
    catch { case _: NumberFormatException => None }
wenzelm@38355
    21
wenzelm@38355
    22
  def get_long(name: String, props: List[(String, String)]): Option[Long] =
wenzelm@38355
    23
  {
wenzelm@38355
    24
    get_string(name, props) match {
wenzelm@38355
    25
      case None => None
wenzelm@38355
    26
      case Some(value) => parse_long(value)
wenzelm@38355
    27
    }
wenzelm@38355
    28
  }
wenzelm@38355
    29
wenzelm@38355
    30
wenzelm@36683
    31
  def parse_int(s: String): Option[Int] =
wenzelm@36683
    32
    try { Some(Integer.parseInt(s)) }
wenzelm@36683
    33
    catch { case _: NumberFormatException => None }
wenzelm@36683
    34
wenzelm@36683
    35
  def get_int(name: String, props: List[(String, String)]): Option[Int] =
wenzelm@36683
    36
  {
wenzelm@36683
    37
    get_string(name, props) match {
wenzelm@36683
    38
      case None => None
wenzelm@36683
    39
      case Some(value) => parse_int(value)
wenzelm@36683
    40
    }
wenzelm@36683
    41
  }
wenzelm@36683
    42
wenzelm@36683
    43
wenzelm@29184
    44
  /* name */
wenzelm@29184
    45
wenzelm@29184
    46
  val NAME = "name"
wenzelm@29184
    47
  val KIND = "kind"
wenzelm@29184
    48
wenzelm@29184
    49
wenzelm@33088
    50
  /* formal entities */
wenzelm@33088
    51
wenzelm@33088
    52
  val ENTITY = "entity"
wenzelm@33088
    53
  val DEF = "def"
wenzelm@33088
    54
  val REF = "ref"
wenzelm@33088
    55
wenzelm@33088
    56
wenzelm@27970
    57
  /* position */
wenzelm@27970
    58
wenzelm@27970
    59
  val LINE = "line"
wenzelm@27970
    60
  val COLUMN = "column"
wenzelm@27970
    61
  val OFFSET = "offset"
wenzelm@27970
    62
  val END_LINE = "end_line"
wenzelm@27970
    63
  val END_COLUMN = "end_column"
wenzelm@27970
    64
  val END_OFFSET = "end_offset"
wenzelm@27970
    65
  val FILE = "file"
wenzelm@27970
    66
  val ID = "id"
wenzelm@27970
    67
wenzelm@32450
    68
  val POSITION_PROPERTIES =
wenzelm@32450
    69
    Set(LINE, COLUMN, OFFSET, END_LINE, END_COLUMN, END_OFFSET, FILE, ID)
wenzelm@29205
    70
wenzelm@29184
    71
  val POSITION = "position"
wenzelm@29184
    72
  val LOCATION = "location"
wenzelm@29184
    73
wenzelm@29184
    74
wenzelm@36683
    75
  /* pretty printing */
wenzelm@36683
    76
wenzelm@36683
    77
  val INDENT = "indent"
wenzelm@36683
    78
  val BLOCK = "block"
wenzelm@36683
    79
  val WIDTH = "width"
wenzelm@36683
    80
  val BREAK = "break"
wenzelm@36683
    81
wenzelm@36683
    82
wenzelm@33985
    83
  /* hidden text */
wenzelm@33985
    84
wenzelm@33985
    85
  val HIDDEN = "hidden"
wenzelm@33985
    86
wenzelm@33985
    87
wenzelm@29184
    88
  /* logical entities */
wenzelm@29184
    89
wenzelm@29184
    90
  val TCLASS = "tclass"
wenzelm@29184
    91
  val TYCON = "tycon"
wenzelm@29184
    92
  val FIXED_DECL = "fixed_decl"
wenzelm@29184
    93
  val FIXED = "fixed"
wenzelm@29184
    94
  val CONST_DECL = "const_decl"
wenzelm@29184
    95
  val CONST = "const"
wenzelm@29184
    96
  val FACT_DECL = "fact_decl"
wenzelm@29184
    97
  val FACT = "fact"
wenzelm@29184
    98
  val DYNAMIC_FACT = "dynamic_fact"
wenzelm@29184
    99
  val LOCAL_FACT_DECL = "local_fact_decl"
wenzelm@29184
   100
  val LOCAL_FACT = "local_fact"
wenzelm@29184
   101
wenzelm@29184
   102
wenzelm@29184
   103
  /* inner syntax */
wenzelm@29184
   104
wenzelm@29184
   105
  val TFREE = "tfree"
wenzelm@29184
   106
  val TVAR = "tvar"
wenzelm@29184
   107
  val FREE = "free"
wenzelm@29184
   108
  val SKOLEM = "skolem"
wenzelm@29184
   109
  val BOUND = "bound"
wenzelm@29184
   110
  val VAR = "var"
wenzelm@29184
   111
  val NUM = "num"
wenzelm@29184
   112
  val FLOAT = "float"
wenzelm@29184
   113
  val XNUM = "xnum"
wenzelm@29184
   114
  val XSTR = "xstr"
wenzelm@29184
   115
  val LITERAL = "literal"
wenzelm@29184
   116
  val INNER_COMMENT = "inner_comment"
wenzelm@29184
   117
wenzelm@29184
   118
  val SORT = "sort"
wenzelm@29184
   119
  val TYP = "typ"
wenzelm@29184
   120
  val TERM = "term"
wenzelm@29184
   121
  val PROP = "prop"
wenzelm@29184
   122
wenzelm@29184
   123
  val ATTRIBUTE = "attribute"
wenzelm@29184
   124
  val METHOD = "method"
wenzelm@29184
   125
wenzelm@29184
   126
wenzelm@29184
   127
  /* embedded source text */
wenzelm@29184
   128
wenzelm@29184
   129
  val ML_SOURCE = "ML_source"
wenzelm@29184
   130
  val DOC_SOURCE = "doc_source"
wenzelm@29184
   131
wenzelm@29184
   132
  val ANTIQ = "antiq"
wenzelm@29184
   133
  val ML_ANTIQ = "ML_antiq"
wenzelm@29184
   134
  val DOC_ANTIQ = "doc_antiq"
wenzelm@29184
   135
wenzelm@29184
   136
wenzelm@30615
   137
  /* ML syntax */
wenzelm@30615
   138
wenzelm@30615
   139
  val ML_KEYWORD = "ML_keyword"
wenzelm@37195
   140
  val ML_DELIMITER = "ML_delimiter"
wenzelm@30615
   141
  val ML_IDENT = "ML_ident"
wenzelm@30615
   142
  val ML_TVAR = "ML_tvar"
wenzelm@30615
   143
  val ML_NUMERAL = "ML_numeral"
wenzelm@30615
   144
  val ML_CHAR = "ML_char"
wenzelm@30615
   145
  val ML_STRING = "ML_string"
wenzelm@30615
   146
  val ML_COMMENT = "ML_comment"
wenzelm@30615
   147
  val ML_MALFORMED = "ML_malformed"
wenzelm@30615
   148
wenzelm@30702
   149
  val ML_DEF = "ML_def"
wenzelm@31472
   150
  val ML_OPEN = "ML_open"
wenzelm@31472
   151
  val ML_STRUCT = "ML_struct"
wenzelm@30702
   152
  val ML_REF = "ML_ref"
wenzelm@30702
   153
  val ML_TYPING = "ML_typing"
wenzelm@30702
   154
wenzelm@30615
   155
wenzelm@29184
   156
  /* outer syntax */
wenzelm@29184
   157
wenzelm@29184
   158
  val KEYWORD_DECL = "keyword_decl"
wenzelm@29184
   159
  val COMMAND_DECL = "command_decl"
wenzelm@29184
   160
wenzelm@29184
   161
  val KEYWORD = "keyword"
wenzelm@37194
   162
  val OPERATOR = "operator"
wenzelm@29184
   163
  val COMMAND = "command"
wenzelm@29184
   164
  val IDENT = "ident"
wenzelm@29184
   165
  val STRING = "string"
wenzelm@29184
   166
  val ALTSTRING = "altstring"
wenzelm@29184
   167
  val VERBATIM = "verbatim"
wenzelm@29184
   168
  val COMMENT = "comment"
wenzelm@29184
   169
  val CONTROL = "control"
wenzelm@29184
   170
  val MALFORMED = "malformed"
wenzelm@29184
   171
wenzelm@29185
   172
  val COMMAND_SPAN = "command_span"
wenzelm@29185
   173
  val IGNORED_SPAN = "ignored_span"
wenzelm@29185
   174
  val MALFORMED_SPAN = "malformed_span"
wenzelm@29185
   175
wenzelm@29184
   176
wenzelm@29184
   177
  /* toplevel */
wenzelm@29184
   178
wenzelm@29184
   179
  val STATE = "state"
wenzelm@29184
   180
  val SUBGOAL = "subgoal"
wenzelm@29184
   181
  val SENDBACK = "sendback"
wenzelm@29184
   182
  val HILITE = "hilite"
wenzelm@29184
   183
wenzelm@29184
   184
wenzelm@29184
   185
  /* command status */
wenzelm@29184
   186
wenzelm@29417
   187
  val TASK = "task"
wenzelm@29417
   188
wenzelm@29184
   189
  val UNPROCESSED = "unprocessed"
wenzelm@29184
   190
  val RUNNING = "running"
wenzelm@37186
   191
  val FORKED = "forked"
wenzelm@37186
   192
  val JOINED = "joined"
wenzelm@29184
   193
  val FAILED = "failed"
wenzelm@29184
   194
  val FINISHED = "finished"
wenzelm@29184
   195
  val DISPOSED = "disposed"
wenzelm@29488
   196
wenzelm@29488
   197
wenzelm@29488
   198
  /* interactive documents */
wenzelm@29488
   199
wenzelm@38231
   200
  val Assign = Markup("assign", Nil)
wenzelm@29488
   201
  val EDIT = "edit"
wenzelm@29184
   202
wenzelm@27970
   203
wenzelm@27970
   204
  /* messages */
wenzelm@27970
   205
wenzelm@27970
   206
  val PID = "pid"
wenzelm@27970
   207
wenzelm@29195
   208
  val MESSAGE = "message"
wenzelm@29522
   209
  val CLASS = "class"
wenzelm@29522
   210
wenzelm@29522
   211
  val INIT = "init"
wenzelm@29522
   212
  val STATUS = "status"
wenzelm@38236
   213
  val REPORT = "report"
wenzelm@29522
   214
  val WRITELN = "writeln"
wenzelm@29522
   215
  val TRACING = "tracing"
wenzelm@29522
   216
  val WARNING = "warning"
wenzelm@29522
   217
  val ERROR = "error"
wenzelm@29522
   218
  val DEBUG = "debug"
wenzelm@29522
   219
  val SYSTEM = "system"
wenzelm@38259
   220
  val INPUT = "input"
wenzelm@29522
   221
  val STDIN = "stdin"
wenzelm@29522
   222
  val STDOUT = "stdout"
wenzelm@29522
   223
  val SIGNAL = "signal"
wenzelm@29522
   224
  val EXIT = "exit"
wenzelm@29195
   225
wenzelm@38231
   226
  val Ready = Markup("ready", Nil)
wenzelm@31384
   227
wenzelm@27970
   228
wenzelm@34119
   229
  /* system data */
wenzelm@27970
   230
wenzelm@38231
   231
  val Data = Markup("data", Nil)
wenzelm@27958
   232
}
wenzelm@38230
   233
wenzelm@38230
   234
sealed case class Markup(name: String, properties: List[(String, String)])