src/Pure/PIDE/isabelle_markup.scala
author wenzelm
Fri Sep 14 18:12:41 2012 +0200 (2012-09-14 ago)
changeset 49358 0fa351b1bd14
parent 49321 a48f9bbbe720
child 49418 c451856129cd
permissions -rw-r--r--
clarified markup names;
     1 /*  Title:      Pure/PIDE/isabelle_markup.scala
     2     Author:     Makarius
     3 
     4 Isabelle markup elements.
     5 */
     6 
     7 package isabelle
     8 
     9 
    10 object Isabelle_Markup
    11 {
    12   /* formal entities */
    13 
    14   val BINDING = "binding"
    15   val ENTITY = "entity"
    16   val DEF = "def"
    17   val REF = "ref"
    18 
    19   object Entity
    20   {
    21     def unapply(markup: Markup): Option[(String, String)] =
    22       markup match {
    23         case Markup(ENTITY, props @ Markup.Kind(kind)) =>
    24           props match {
    25             case Markup.Name(name) => Some(kind, name)
    26             case _ => None
    27           }
    28         case _ => None
    29       }
    30   }
    31 
    32 
    33   /* position */
    34 
    35   val LINE = "line"
    36   val OFFSET = "offset"
    37   val END_OFFSET = "end_offset"
    38   val FILE = "file"
    39   val ID = "id"
    40 
    41   val DEF_LINE = "def_line"
    42   val DEF_OFFSET = "def_offset"
    43   val DEF_END_OFFSET = "def_end_offset"
    44   val DEF_FILE = "def_file"
    45   val DEF_ID = "def_id"
    46 
    47   val POSITION_PROPERTIES = Set(LINE, OFFSET, END_OFFSET, FILE, ID)
    48   val POSITION = "position"
    49 
    50 
    51   /* path */
    52 
    53   val PATH = "path"
    54 
    55   object Path
    56   {
    57     def unapply(markup: Markup): Option[String] =
    58       markup match {
    59         case Markup(PATH, Markup.Name(name)) => Some(name)
    60         case _ => None
    61       }
    62   }
    63 
    64 
    65   /* pretty printing */
    66 
    67   val Indent = new Properties.Int("indent")
    68   val BLOCK = "block"
    69   val Width = new Properties.Int("width")
    70   val BREAK = "break"
    71 
    72 
    73   /* hidden text */
    74 
    75   val HIDDEN = "hidden"
    76 
    77 
    78   /* logical entities */
    79 
    80   val CLASS = "class"
    81   val TYPE_NAME = "type_name"
    82   val FIXED = "fixed"
    83   val CONSTANT = "constant"
    84 
    85   val DYNAMIC_FACT = "dynamic_fact"
    86 
    87 
    88   /* inner syntax */
    89 
    90   val TFREE = "tfree"
    91   val TVAR = "tvar"
    92   val FREE = "free"
    93   val SKOLEM = "skolem"
    94   val BOUND = "bound"
    95   val VAR = "var"
    96   val NUMERAL = "numeral"
    97   val LITERAL = "literal"
    98   val DELIMITER = "delimiter"
    99   val INNER_STRING = "inner_string"
   100   val INNER_COMMENT = "inner_comment"
   101 
   102   val TOKEN_RANGE = "token_range"
   103 
   104   val SORT = "sort"
   105   val TYP = "typ"
   106   val TERM = "term"
   107   val PROP = "prop"
   108 
   109   val TYPING = "typing"
   110 
   111   val ATTRIBUTE = "attribute"
   112   val METHOD = "method"
   113 
   114 
   115   /* embedded source text */
   116 
   117   val ML_SOURCE = "ML_source"
   118   val DOCUMENT_SOURCE = "document_source"
   119 
   120   val ANTIQ = "antiq"
   121   val ML_ANTIQUOTATION = "ML_antiquotation"
   122   val DOCUMENT_ANTIQUOTATION = "document_antiquotation"
   123   val DOCUMENT_ANTIQUOTATION_OPTION = "document_antiquotation_option"
   124 
   125 
   126   /* ML syntax */
   127 
   128   val ML_KEYWORD = "ML_keyword"
   129   val ML_DELIMITER = "ML_delimiter"
   130   val ML_TVAR = "ML_tvar"
   131   val ML_NUMERAL = "ML_numeral"
   132   val ML_CHAR = "ML_char"
   133   val ML_STRING = "ML_string"
   134   val ML_COMMENT = "ML_comment"
   135 
   136   val ML_DEF = "ML_def"
   137   val ML_OPEN = "ML_open"
   138   val ML_STRUCT = "ML_struct"
   139   val ML_TYPING = "ML_typing"
   140 
   141 
   142   /* outer syntax */
   143 
   144   val KEYWORD = "keyword"
   145   val OPERATOR = "operator"
   146   val COMMAND = "command"
   147   val STRING = "string"
   148   val ALTSTRING = "altstring"
   149   val VERBATIM = "verbatim"
   150   val COMMENT = "comment"
   151   val CONTROL = "control"
   152 
   153 
   154   /* timing */
   155 
   156   val TIMING = "timing"
   157   val ELAPSED = "elapsed"
   158   val CPU = "cpu"
   159   val GC = "gc"
   160 
   161   object Timing
   162   {
   163     def apply(timing: isabelle.Timing): Markup =
   164       Markup(TIMING, List(
   165         (ELAPSED, Properties.Value.Double(timing.elapsed.seconds)),
   166         (CPU, Properties.Value.Double(timing.cpu.seconds)),
   167         (GC, Properties.Value.Double(timing.gc.seconds))))
   168     def unapply(markup: Markup): Option[isabelle.Timing] =
   169       markup match {
   170         case Markup(TIMING, List(
   171           (ELAPSED, Properties.Value.Double(elapsed)),
   172           (CPU, Properties.Value.Double(cpu)),
   173           (GC, Properties.Value.Double(gc)))) =>
   174             Some(new isabelle.Timing(Time.seconds(elapsed), Time.seconds(cpu), Time.seconds(gc)))
   175         case _ => None
   176       }
   177   }
   178 
   179 
   180   /* toplevel */
   181 
   182   val SUBGOALS = "subgoals"
   183   val PROOF_STATE = "proof_state"
   184 
   185   val STATE = "state"
   186   val SUBGOAL = "subgoal"
   187   val SENDBACK = "sendback"
   188   val INTENSIFY = "intensify"
   189 
   190 
   191   /* command status */
   192 
   193   val TASK = "task"
   194 
   195   val ACCEPTED = "accepted"
   196   val FORKED = "forked"
   197   val JOINED = "joined"
   198   val RUNNING = "running"
   199   val FINISHED = "finished"
   200   val FAILED = "failed"
   201 
   202 
   203   /* interactive documents */
   204 
   205   val VERSION = "version"
   206   val ASSIGN = "assign"
   207 
   208 
   209   /* prover process */
   210 
   211   val PROVER_COMMAND = "prover_command"
   212   val PROVER_ARG = "prover_arg"
   213 
   214 
   215   /* messages */
   216 
   217   val Serial = new Properties.Long("serial")
   218 
   219   val MESSAGE = "message"
   220 
   221   val INIT = "init"
   222   val STATUS = "status"
   223   val REPORT = "report"
   224   val WRITELN = "writeln"
   225   val TRACING = "tracing"
   226   val WARNING = "warning"
   227   val ERROR = "error"
   228   val PROTOCOL = "protocol"
   229   val SYSTEM = "system"
   230   val STDOUT = "stdout"
   231   val STDERR = "stderr"
   232   val EXIT = "exit"
   233 
   234   val Return_Code = new Properties.Int("return_code")
   235 
   236   val LEGACY = "legacy"
   237 
   238   val NO_REPORT = "no_report"
   239 
   240   val BAD = "bad"
   241 
   242 
   243   /* protocol message functions */
   244 
   245   val FUNCTION = "function"
   246   val Function = new Properties.String(FUNCTION)
   247 
   248   val Assign_Execs: Properties.T = List((FUNCTION, "assign_execs"))
   249   val Removed_Versions: Properties.T = List((FUNCTION, "removed_versions"))
   250 
   251   object Invoke_Scala
   252   {
   253     def unapply(props: Properties.T): Option[(String, String)] =
   254       props match {
   255         case List((FUNCTION, "invoke_scala"), (Markup.NAME, name), (ID, id)) => Some((name, id))
   256         case _ => None
   257       }
   258   }
   259   object Cancel_Scala
   260   {
   261     def unapply(props: Properties.T): Option[String] =
   262       props match {
   263         case List((FUNCTION, "cancel_scala"), (ID, id)) => Some(id)
   264         case _ => None
   265       }
   266   }
   267 }
   268