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