src/Pure/PIDE/isabelle_markup.scala
author wenzelm
Tue Mar 13 21:17:37 2012 +0100 (2012-03-13 ago)
changeset 46910 3e068ef04b42
parent 46774 38f113b052b1
child 47395 e6261a493f04
permissions -rw-r--r--
clarified command state -- markup within proper_range, excluding trailing whitespace;
     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 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 = "keyword"
   146   val OPERATOR = "operator"
   147   val COMMAND = "command"
   148   val STRING = "string"
   149   val ALTSTRING = "altstring"
   150   val VERBATIM = "verbatim"
   151   val COMMENT = "comment"
   152   val CONTROL = "control"
   153   val MALFORMED = "malformed"
   154 
   155   val COMMAND_SPAN = "command_span"
   156   val IGNORED_SPAN = "ignored_span"
   157   val MALFORMED_SPAN = "malformed_span"
   158 
   159 
   160   /* timing */
   161 
   162   val TIMING = "timing"
   163   val ELAPSED = "elapsed"
   164   val CPU = "cpu"
   165   val GC = "gc"
   166 
   167   object Timing
   168   {
   169     def apply(timing: isabelle.Timing): Markup =
   170       Markup(TIMING, List(
   171         (ELAPSED, Properties.Value.Double(timing.elapsed.seconds)),
   172         (CPU, Properties.Value.Double(timing.cpu.seconds)),
   173         (GC, Properties.Value.Double(timing.gc.seconds))))
   174     def unapply(markup: Markup): Option[isabelle.Timing] =
   175       markup match {
   176         case Markup(TIMING, List(
   177           (ELAPSED, Properties.Value.Double(elapsed)),
   178           (CPU, Properties.Value.Double(cpu)),
   179           (GC, Properties.Value.Double(gc)))) =>
   180             Some(new isabelle.Timing(Time.seconds(elapsed), Time.seconds(cpu), Time.seconds(gc)))
   181         case _ => None
   182       }
   183   }
   184 
   185 
   186   /* toplevel */
   187 
   188   val SUBGOALS = "subgoals"
   189   val PROOF_STATE = "proof_state"
   190 
   191   val STATE = "state"
   192   val SUBGOAL = "subgoal"
   193   val SENDBACK = "sendback"
   194   val HILITE = "hilite"
   195 
   196 
   197   /* command status */
   198 
   199   val TASK = "task"
   200 
   201   val PARSED = "parsed"
   202   val FORKED = "forked"
   203   val JOINED = "joined"
   204   val FAILED = "failed"
   205   val FINISHED = "finished"
   206 
   207 
   208   /* interactive documents */
   209 
   210   val VERSION = "version"
   211   val ASSIGN = "assign"
   212 
   213 
   214   /* prover process */
   215 
   216   val PROVER_COMMAND = "prover_command"
   217   val PROVER_ARG = "prover_arg"
   218 
   219 
   220   /* messages */
   221 
   222   val Serial = new Properties.Long("serial")
   223 
   224   val MESSAGE = "message"
   225 
   226   val INIT = "init"
   227   val STATUS = "status"
   228   val REPORT = "report"
   229   val WRITELN = "writeln"
   230   val TRACING = "tracing"
   231   val WARNING = "warning"
   232   val ERROR = "error"
   233   val PROTOCOL = "protocol"
   234   val SYSTEM = "system"
   235   val STDOUT = "stdout"
   236   val STDERR = "stderr"
   237   val EXIT = "exit"
   238 
   239   val LEGACY = "legacy"
   240 
   241   val NO_REPORT = "no_report"
   242 
   243   val BAD = "bad"
   244 
   245 
   246   /* protocol message functions */
   247 
   248   val FUNCTION = "function"
   249   val Function = new Properties.String(FUNCTION)
   250 
   251   val Ready: Properties.T = List((FUNCTION, "ready"))
   252 
   253   object Loaded_Theory
   254   {
   255     def unapply(props: Properties.T): Option[String] =
   256       props match {
   257         case List((FUNCTION, "loaded_theory"), (Markup.NAME, name)) => Some(name)
   258         case _ => None
   259       }
   260   }
   261 
   262   object Keyword_Decl
   263   {
   264     def unapply(props: Properties.T): Option[String] =
   265       props match {
   266         case List((FUNCTION, "keyword_decl"), (Markup.NAME, name)) => Some(name)
   267         case _ => None
   268       }
   269   }
   270   object Command_Decl
   271   {
   272     def unapply(props: Properties.T): Option[(String, String)] =
   273       props match {
   274         case List((FUNCTION, "command_decl"), (Markup.NAME, name), (Markup.KIND, kind)) =>
   275           Some((name, kind))
   276         case _ => None
   277       }
   278   }
   279 
   280   val Assign_Execs: Properties.T = List((FUNCTION, "assign_execs"))
   281   val Removed_Versions: Properties.T = List((FUNCTION, "removed_versions"))
   282 
   283   object Invoke_Scala
   284   {
   285     def unapply(props: Properties.T): Option[(String, String)] =
   286       props match {
   287         case List((FUNCTION, "invoke_scala"), (Markup.NAME, name), (ID, id)) => Some((name, id))
   288         case _ => None
   289       }
   290   }
   291   object Cancel_Scala
   292   {
   293     def unapply(props: Properties.T): Option[String] =
   294       props match {
   295         case List((FUNCTION, "cancel_scala"), (ID, id)) => Some(id)
   296         case _ => None
   297       }
   298   }
   299 }
   300