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