src/Pure/PIDE/markup.scala
author wenzelm
Sat Jul 13 13:25:42 2013 +0200 (2013-07-13 ago)
changeset 52643 34c29356930e
parent 52563 f9a20c2c3b70
child 52697 6fb98a20c349
permissions -rw-r--r--
more explicit Markup.information for messages produced by "auto" tools;
     1 /*  Title:      Pure/PIDE/markup.scala
     2     Module:     PIDE
     3     Author:     Makarius
     4 
     5 Isabelle-specific implementation of quasi-abstract markup elements.
     6 */
     7 
     8 package isabelle
     9 
    10 
    11 object Markup
    12 {
    13   /* properties */
    14 
    15   val NAME = "name"
    16   val Name = new Properties.String(NAME)
    17 
    18   val KIND = "kind"
    19   val Kind = new Properties.String(KIND)
    20 
    21 
    22   /* basic markup */
    23 
    24   val Empty = Markup("", Nil)
    25   val Broken = Markup("broken", Nil)
    26 
    27 
    28   /* formal entities */
    29 
    30   val BINDING = "binding"
    31   val ENTITY = "entity"
    32   val DEF = "def"
    33   val REF = "ref"
    34 
    35   object Entity
    36   {
    37     def unapply(markup: Markup): Option[(String, String)] =
    38       markup match {
    39         case Markup(ENTITY, props @ Kind(kind)) =>
    40           props match {
    41             case Name(name) => Some(kind, name)
    42             case _ => None
    43           }
    44         case _ => None
    45       }
    46   }
    47 
    48 
    49   /* position */
    50 
    51   val LINE = "line"
    52   val OFFSET = "offset"
    53   val END_OFFSET = "end_offset"
    54   val FILE = "file"
    55   val ID = "id"
    56 
    57   val DEF_LINE = "def_line"
    58   val DEF_OFFSET = "def_offset"
    59   val DEF_END_OFFSET = "def_end_offset"
    60   val DEF_FILE = "def_file"
    61   val DEF_ID = "def_id"
    62 
    63   val POSITION_PROPERTIES = Set(LINE, OFFSET, END_OFFSET, FILE, ID)
    64   val POSITION = "position"
    65 
    66 
    67   /* path */
    68 
    69   val PATH = "path"
    70 
    71   object Path
    72   {
    73     def unapply(markup: Markup): Option[String] =
    74       markup match {
    75         case Markup(PATH, Name(name)) => Some(name)
    76         case _ => None
    77       }
    78   }
    79 
    80 
    81   /* pretty printing */
    82 
    83   val Indent = new Properties.Int("indent")
    84   val BLOCK = "block"
    85 
    86   val Width = new Properties.Int("width")
    87   val BREAK = "break"
    88 
    89   val ITEM = "item"
    90   val BULLET = "bullet"
    91 
    92   val SEPARATOR = "separator"
    93 
    94 
    95   /* hidden text */
    96 
    97   val HIDDEN = "hidden"
    98 
    99 
   100   /* logical entities */
   101 
   102   val CLASS = "class"
   103   val TYPE_NAME = "type_name"
   104   val FIXED = "fixed"
   105   val CONSTANT = "constant"
   106 
   107   val DYNAMIC_FACT = "dynamic_fact"
   108 
   109 
   110   /* inner syntax */
   111 
   112   val TFREE = "tfree"
   113   val TVAR = "tvar"
   114   val FREE = "free"
   115   val SKOLEM = "skolem"
   116   val BOUND = "bound"
   117   val VAR = "var"
   118   val NUMERAL = "numeral"
   119   val LITERAL = "literal"
   120   val DELIMITER = "delimiter"
   121   val INNER_STRING = "inner_string"
   122   val INNER_COMMENT = "inner_comment"
   123 
   124   val TOKEN_RANGE = "token_range"
   125 
   126   val SORT = "sort"
   127   val TYP = "typ"
   128   val TERM = "term"
   129   val PROP = "prop"
   130 
   131   val SORTING = "sorting"
   132   val TYPING = "typing"
   133 
   134   val ATTRIBUTE = "attribute"
   135   val METHOD = "method"
   136 
   137 
   138   /* embedded source text */
   139 
   140   val ML_SOURCE = "ML_source"
   141   val DOCUMENT_SOURCE = "document_source"
   142 
   143   val ANTIQ = "antiq"
   144   val ML_ANTIQUOTATION = "ML_antiquotation"
   145   val DOCUMENT_ANTIQUOTATION = "document_antiquotation"
   146   val DOCUMENT_ANTIQUOTATION_OPTION = "document_antiquotation_option"
   147 
   148 
   149   /* text structure */
   150 
   151   val PARAGRAPH = "paragraph"
   152   val TEXT_FOLD = "text_fold"
   153 
   154 
   155   /* ML syntax */
   156 
   157   val ML_KEYWORD = "ML_keyword"
   158   val ML_DELIMITER = "ML_delimiter"
   159   val ML_TVAR = "ML_tvar"
   160   val ML_NUMERAL = "ML_numeral"
   161   val ML_CHAR = "ML_char"
   162   val ML_STRING = "ML_string"
   163   val ML_COMMENT = "ML_comment"
   164 
   165   val ML_DEF = "ML_def"
   166   val ML_OPEN = "ML_open"
   167   val ML_STRUCT = "ML_struct"
   168   val ML_TYPING = "ML_typing"
   169 
   170 
   171   /* outer syntax */
   172 
   173   val KEYWORD = "keyword"
   174   val OPERATOR = "operator"
   175   val COMMAND = "command"
   176   val STRING = "string"
   177   val ALTSTRING = "altstring"
   178   val VERBATIM = "verbatim"
   179   val COMMENT = "comment"
   180   val CONTROL = "control"
   181 
   182   val KEYWORD1 = "keyword1"
   183   val KEYWORD2 = "keyword2"
   184 
   185 
   186   /* timing */
   187 
   188   val Elapsed = new Properties.Double("elapsed")
   189   val CPU = new Properties.Double("cpu")
   190   val GC = new Properties.Double("gc")
   191 
   192   object Timing_Properties
   193   {
   194     def apply(timing: isabelle.Timing): Properties.T =
   195       Elapsed(timing.elapsed.seconds) ::: CPU(timing.cpu.seconds) ::: GC(timing.gc.seconds)
   196 
   197     def unapply(props: Properties.T): Option[isabelle.Timing] =
   198       (props, props, props) match {
   199         case (Elapsed(elapsed), CPU(cpu), GC(gc)) =>
   200           Some(new isabelle.Timing(Time.seconds(elapsed), Time.seconds(cpu), Time.seconds(gc)))
   201         case _ => None
   202       }
   203   }
   204 
   205   val TIMING = "timing"
   206 
   207   object Timing
   208   {
   209     def apply(timing: isabelle.Timing): Markup = Markup(TIMING, Timing_Properties(timing))
   210 
   211     def unapply(markup: Markup): Option[isabelle.Timing] =
   212       markup match {
   213         case Markup(TIMING, Timing_Properties(timing)) => Some(timing)
   214         case _ => None
   215       }
   216   }
   217 
   218 
   219   /* command timing */
   220 
   221   val COMMAND_TIMING = "command_timing"
   222 
   223 
   224   /* toplevel */
   225 
   226   val SUBGOALS = "subgoals"
   227   val PROOF_STATE = "proof_state"
   228 
   229   val STATE = "state"
   230   val GOAL = "goal"
   231   val SUBGOAL = "subgoal"
   232 
   233 
   234   /* command status */
   235 
   236   val TASK = "task"
   237 
   238   val ACCEPTED = "accepted"
   239   val FORKED = "forked"
   240   val JOINED = "joined"
   241   val RUNNING = "running"
   242   val FINISHED = "finished"
   243   val FAILED = "failed"
   244 
   245 
   246   /* interactive documents */
   247 
   248   val VERSION = "version"
   249   val ASSIGN = "assign"
   250 
   251 
   252   /* prover process */
   253 
   254   val PROVER_COMMAND = "prover_command"
   255   val PROVER_ARG = "prover_arg"
   256 
   257 
   258   /* messages */
   259 
   260   val Serial = new Properties.Long("serial")
   261 
   262   val MESSAGE = "message"
   263 
   264   val INIT = "init"
   265   val STATUS = "status"
   266   val REPORT = "report"
   267   val RESULT = "result"
   268   val WRITELN = "writeln"
   269   val TRACING = "tracing"
   270   val WARNING = "warning"
   271   val ERROR = "error"
   272   val PROTOCOL = "protocol"
   273   val SYSTEM = "system"
   274   val STDOUT = "stdout"
   275   val STDERR = "stderr"
   276   val EXIT = "exit"
   277 
   278   val WRITELN_MESSAGE = "writeln_message"
   279   val TRACING_MESSAGE = "tracing_message"
   280   val WARNING_MESSAGE = "warning_message"
   281   val ERROR_MESSAGE = "error_message"
   282 
   283   val message: String => String =
   284     Map(WRITELN -> WRITELN_MESSAGE, TRACING -> TRACING_MESSAGE,
   285         WARNING -> WARNING_MESSAGE, ERROR -> ERROR_MESSAGE).withDefault((s: String) => s)
   286 
   287   val Return_Code = new Properties.Int("return_code")
   288 
   289   val LEGACY = "legacy"
   290 
   291   val NO_REPORT = "no_report"
   292 
   293   val BAD = "bad"
   294 
   295   val INTENSIFY = "intensify"
   296   val INFORMATION = "information"
   297 
   298 
   299   /* active areas */
   300 
   301   val BROWSER = "browser"
   302   val GRAPHVIEW = "graphview"
   303 
   304   val SENDBACK = "sendback"
   305   val PADDING = "padding"
   306   val PADDING_LINE = (PADDING, LINE)
   307 
   308   val DIALOG = "dialog"
   309   val Result = new Properties.String(RESULT)
   310 
   311 
   312   /* protocol message functions */
   313 
   314   val FUNCTION = "function"
   315   val Function = new Properties.String(FUNCTION)
   316 
   317   val Assign_Update: Properties.T = List((FUNCTION, "assign_update"))
   318   val Removed_Versions: Properties.T = List((FUNCTION, "removed_versions"))
   319 
   320   object Protocol_Handler
   321   {
   322     def unapply(props: Properties.T): Option[(String)] =
   323       props match {
   324         case List((FUNCTION, "protocol_handler"), (NAME, name)) => Some(name)
   325         case _ => None
   326       }
   327   }
   328 
   329   val INVOKE_SCALA = "invoke_scala"
   330   object Invoke_Scala
   331   {
   332     def unapply(props: Properties.T): Option[(String, String)] =
   333       props match {
   334         case List((FUNCTION, INVOKE_SCALA), (NAME, name), (ID, id)) => Some((name, id))
   335         case _ => None
   336       }
   337   }
   338 
   339   val CANCEL_SCALA = "cancel_scala"
   340   object Cancel_Scala
   341   {
   342     def unapply(props: Properties.T): Option[String] =
   343       props match {
   344         case List((FUNCTION, CANCEL_SCALA), (ID, id)) => Some(id)
   345         case _ => None
   346       }
   347   }
   348 
   349   object ML_Statistics
   350   {
   351     def unapply(props: Properties.T): Option[Properties.T] =
   352       props match {
   353         case (FUNCTION, "ML_statistics") :: stats => Some(stats)
   354         case _ => None
   355       }
   356   }
   357 
   358   object Task_Statistics
   359   {
   360     def unapply(props: Properties.T): Option[Properties.T] =
   361       props match {
   362         case (FUNCTION, "task_statistics") :: stats => Some(stats)
   363         case _ => None
   364       }
   365   }
   366 }
   367 
   368 
   369 sealed case class Markup(name: String, properties: Properties.T)
   370