src/Pure/PIDE/isabelle_markup.scala
author wenzelm
Thu Jan 05 14:15:37 2012 +0100 (2012-01-05 ago)
changeset 46121 30a69cd8a9a0
parent 45702 7df60d1aa988
child 46122 1e9ec1a44dfc
permissions -rw-r--r--
prefer raw_message for protocol implementation;
     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 = "type"
    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 DOC_SOURCE = "doc_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   val ML_MALFORMED = "ML_malformed"
   136 
   137   val ML_DEF = "ML_def"
   138   val ML_OPEN = "ML_open"
   139   val ML_STRUCT = "ML_struct"
   140   val ML_TYPING = "ML_typing"
   141 
   142 
   143   /* outer syntax */
   144 
   145   val KEYWORD_DECL = "keyword_decl"
   146   val COMMAND_DECL = "command_decl"
   147 
   148   val KEYWORD = "keyword"
   149   val OPERATOR = "operator"
   150   val COMMAND = "command"
   151   val STRING = "string"
   152   val ALTSTRING = "altstring"
   153   val VERBATIM = "verbatim"
   154   val COMMENT = "comment"
   155   val CONTROL = "control"
   156   val MALFORMED = "malformed"
   157 
   158   val COMMAND_SPAN = "command_span"
   159   val IGNORED_SPAN = "ignored_span"
   160   val MALFORMED_SPAN = "malformed_span"
   161 
   162 
   163   /* theory loader */
   164 
   165   val LOADED_THEORY = "loaded_theory"
   166 
   167 
   168   /* timing */
   169 
   170   val TIMING = "timing"
   171   val ELAPSED = "elapsed"
   172   val CPU = "cpu"
   173   val GC = "gc"
   174 
   175   object Timing
   176   {
   177     def apply(timing: isabelle.Timing): Markup =
   178       Markup(TIMING, List(
   179         (ELAPSED, Properties.Value.Double(timing.elapsed.seconds)),
   180         (CPU, Properties.Value.Double(timing.cpu.seconds)),
   181         (GC, Properties.Value.Double(timing.gc.seconds))))
   182     def unapply(markup: Markup): Option[isabelle.Timing] =
   183       markup match {
   184         case Markup(TIMING, List(
   185           (ELAPSED, Properties.Value.Double(elapsed)),
   186           (CPU, Properties.Value.Double(cpu)),
   187           (GC, Properties.Value.Double(gc)))) =>
   188             Some(new isabelle.Timing(Time.seconds(elapsed), Time.seconds(cpu), Time.seconds(gc)))
   189         case _ => None
   190       }
   191   }
   192 
   193 
   194   /* toplevel */
   195 
   196   val SUBGOALS = "subgoals"
   197   val PROOF_STATE = "proof_state"
   198 
   199   val STATE = "state"
   200   val SUBGOAL = "subgoal"
   201   val SENDBACK = "sendback"
   202   val HILITE = "hilite"
   203 
   204 
   205   /* command status */
   206 
   207   val TASK = "task"
   208 
   209   val FORKED = "forked"
   210   val JOINED = "joined"
   211   val FAILED = "failed"
   212   val FINISHED = "finished"
   213 
   214 
   215   /* interactive documents */
   216 
   217   val VERSION = "version"
   218   val ASSIGN = "assign"
   219 
   220 
   221   /* prover process */
   222 
   223   val PROVER_COMMAND = "prover_command"
   224   val PROVER_ARG = "prover_arg"
   225 
   226 
   227   /* messages */
   228 
   229   val Serial = new Properties.Long("serial")
   230 
   231   val MESSAGE = "message"
   232 
   233   val INIT = "init"
   234   val STATUS = "status"
   235   val REPORT = "report"
   236   val WRITELN = "writeln"
   237   val TRACING = "tracing"
   238   val WARNING = "warning"
   239   val ERROR = "error"
   240   val RAW = "raw"
   241   val SYSTEM = "system"
   242   val STDOUT = "stdout"
   243   val STDERR = "stderr"
   244   val EXIT = "exit"
   245 
   246   val LEGACY = "legacy"
   247 
   248   val NO_REPORT = "no_report"
   249 
   250   val BAD = "bad"
   251 
   252 
   253   /* raw message functions */
   254 
   255   val FUNCTION = "function"
   256   val Function = new Properties.String(FUNCTION)
   257 
   258   val Ready: Properties.T = List((FUNCTION, "ready"))
   259 
   260   val Assign_Execs: Properties.T = List((FUNCTION, "assign_execs"))
   261   val Removed_Versions: Properties.T = List((FUNCTION, "removed_versions"))
   262 
   263   val INVOKE_SCALA = "invoke_scala"
   264   object Invoke_Scala
   265   {
   266     def unapply(props: Properties.T): Option[(String, String)] =
   267       props match {
   268         case List((FUNCTION, INVOKE_SCALA), (Markup.NAME, name), (ID, id)) => Some((name, id))
   269         case _ => None
   270       }
   271   }
   272 
   273   val CANCEL_SCALA = "cancel_scala"
   274   object Cancel_Scala
   275   {
   276     def unapply(props: Properties.T): Option[String] =
   277       props match {
   278         case List((FUNCTION, CANCEL_SCALA), (ID, id)) => Some(id)
   279         case _ => None
   280       }
   281   }
   282 }
   283