src/Pure/PIDE/markup.scala
changeset 50201 c26369c9eda6
parent 49613 2f6986e2ef06
child 50215 97959912840a
     1.1 --- a/src/Pure/PIDE/markup.scala	Sun Nov 25 18:50:13 2012 +0100
     1.2 +++ b/src/Pure/PIDE/markup.scala	Sun Nov 25 19:49:24 2012 +0100
     1.3 @@ -2,7 +2,7 @@
     1.4      Module:     PIDE
     1.5      Author:     Makarius
     1.6  
     1.7 -Generic markup elements.
     1.8 +Isabelle-specific implementation of quasi-abstract markup elements.
     1.9  */
    1.10  
    1.11  package isabelle
    1.12 @@ -19,10 +19,290 @@
    1.13    val Kind = new Properties.String(KIND)
    1.14  
    1.15  
    1.16 -  /* elements */
    1.17 +  /* basic markup */
    1.18  
    1.19    val Empty = Markup("", Nil)
    1.20    val Broken = Markup("broken", Nil)
    1.21 +
    1.22 +
    1.23 +  /* formal entities */
    1.24 +
    1.25 +  val BINDING = "binding"
    1.26 +  val ENTITY = "entity"
    1.27 +  val DEF = "def"
    1.28 +  val REF = "ref"
    1.29 +
    1.30 +  object Entity
    1.31 +  {
    1.32 +    def unapply(markup: Markup): Option[(String, String)] =
    1.33 +      markup match {
    1.34 +        case Markup(ENTITY, props @ Kind(kind)) =>
    1.35 +          props match {
    1.36 +            case Name(name) => Some(kind, name)
    1.37 +            case _ => None
    1.38 +          }
    1.39 +        case _ => None
    1.40 +      }
    1.41 +  }
    1.42 +
    1.43 +
    1.44 +  /* position */
    1.45 +
    1.46 +  val LINE = "line"
    1.47 +  val OFFSET = "offset"
    1.48 +  val END_OFFSET = "end_offset"
    1.49 +  val FILE = "file"
    1.50 +  val ID = "id"
    1.51 +
    1.52 +  val DEF_LINE = "def_line"
    1.53 +  val DEF_OFFSET = "def_offset"
    1.54 +  val DEF_END_OFFSET = "def_end_offset"
    1.55 +  val DEF_FILE = "def_file"
    1.56 +  val DEF_ID = "def_id"
    1.57 +
    1.58 +  val POSITION_PROPERTIES = Set(LINE, OFFSET, END_OFFSET, FILE, ID)
    1.59 +  val POSITION = "position"
    1.60 +
    1.61 +
    1.62 +  /* path */
    1.63 +
    1.64 +  val PATH = "path"
    1.65 +
    1.66 +  object Path
    1.67 +  {
    1.68 +    def unapply(markup: Markup): Option[String] =
    1.69 +      markup match {
    1.70 +        case Markup(PATH, Name(name)) => Some(name)
    1.71 +        case _ => None
    1.72 +      }
    1.73 +  }
    1.74 +
    1.75 +
    1.76 +  /* pretty printing */
    1.77 +
    1.78 +  val Indent = new Properties.Int("indent")
    1.79 +  val BLOCK = "block"
    1.80 +  val Width = new Properties.Int("width")
    1.81 +  val BREAK = "break"
    1.82 +
    1.83 +  val SEPARATOR = "separator"
    1.84 +
    1.85 +
    1.86 +  /* hidden text */
    1.87 +
    1.88 +  val HIDDEN = "hidden"
    1.89 +
    1.90 +
    1.91 +  /* logical entities */
    1.92 +
    1.93 +  val CLASS = "class"
    1.94 +  val TYPE_NAME = "type_name"
    1.95 +  val FIXED = "fixed"
    1.96 +  val CONSTANT = "constant"
    1.97 +
    1.98 +  val DYNAMIC_FACT = "dynamic_fact"
    1.99 +
   1.100 +
   1.101 +  /* inner syntax */
   1.102 +
   1.103 +  val TFREE = "tfree"
   1.104 +  val TVAR = "tvar"
   1.105 +  val FREE = "free"
   1.106 +  val SKOLEM = "skolem"
   1.107 +  val BOUND = "bound"
   1.108 +  val VAR = "var"
   1.109 +  val NUMERAL = "numeral"
   1.110 +  val LITERAL = "literal"
   1.111 +  val DELIMITER = "delimiter"
   1.112 +  val INNER_STRING = "inner_string"
   1.113 +  val INNER_COMMENT = "inner_comment"
   1.114 +
   1.115 +  val TOKEN_RANGE = "token_range"
   1.116 +
   1.117 +  val SORT = "sort"
   1.118 +  val TYP = "typ"
   1.119 +  val TERM = "term"
   1.120 +  val PROP = "prop"
   1.121 +
   1.122 +  val SORTING = "sorting"
   1.123 +  val TYPING = "typing"
   1.124 +
   1.125 +  val ATTRIBUTE = "attribute"
   1.126 +  val METHOD = "method"
   1.127 +
   1.128 +
   1.129 +  /* embedded source text */
   1.130 +
   1.131 +  val ML_SOURCE = "ML_source"
   1.132 +  val DOCUMENT_SOURCE = "document_source"
   1.133 +
   1.134 +  val ANTIQ = "antiq"
   1.135 +  val ML_ANTIQUOTATION = "ML_antiquotation"
   1.136 +  val DOCUMENT_ANTIQUOTATION = "document_antiquotation"
   1.137 +  val DOCUMENT_ANTIQUOTATION_OPTION = "document_antiquotation_option"
   1.138 +
   1.139 +
   1.140 +  /* text structure */
   1.141 +
   1.142 +  val PARAGRAPH = "paragraph"
   1.143 +
   1.144 +
   1.145 +  /* ML syntax */
   1.146 +
   1.147 +  val ML_KEYWORD = "ML_keyword"
   1.148 +  val ML_DELIMITER = "ML_delimiter"
   1.149 +  val ML_TVAR = "ML_tvar"
   1.150 +  val ML_NUMERAL = "ML_numeral"
   1.151 +  val ML_CHAR = "ML_char"
   1.152 +  val ML_STRING = "ML_string"
   1.153 +  val ML_COMMENT = "ML_comment"
   1.154 +
   1.155 +  val ML_DEF = "ML_def"
   1.156 +  val ML_OPEN = "ML_open"
   1.157 +  val ML_STRUCT = "ML_struct"
   1.158 +  val ML_TYPING = "ML_typing"
   1.159 +
   1.160 +
   1.161 +  /* outer syntax */
   1.162 +
   1.163 +  val KEYWORD = "keyword"
   1.164 +  val OPERATOR = "operator"
   1.165 +  val COMMAND = "command"
   1.166 +  val STRING = "string"
   1.167 +  val ALTSTRING = "altstring"
   1.168 +  val VERBATIM = "verbatim"
   1.169 +  val COMMENT = "comment"
   1.170 +  val CONTROL = "control"
   1.171 +
   1.172 +  val KEYWORD1 = "keyword1"
   1.173 +  val KEYWORD2 = "keyword2"
   1.174 +
   1.175 +
   1.176 +  /* timing */
   1.177 +
   1.178 +  val TIMING = "timing"
   1.179 +  val ELAPSED = "elapsed"
   1.180 +  val CPU = "cpu"
   1.181 +  val GC = "gc"
   1.182 +
   1.183 +  object Timing
   1.184 +  {
   1.185 +    def apply(timing: isabelle.Timing): Markup =
   1.186 +      Markup(TIMING, List(
   1.187 +        (ELAPSED, Properties.Value.Double(timing.elapsed.seconds)),
   1.188 +        (CPU, Properties.Value.Double(timing.cpu.seconds)),
   1.189 +        (GC, Properties.Value.Double(timing.gc.seconds))))
   1.190 +    def unapply(markup: Markup): Option[isabelle.Timing] =
   1.191 +      markup match {
   1.192 +        case Markup(TIMING, List(
   1.193 +          (ELAPSED, Properties.Value.Double(elapsed)),
   1.194 +          (CPU, Properties.Value.Double(cpu)),
   1.195 +          (GC, Properties.Value.Double(gc)))) =>
   1.196 +            Some(new isabelle.Timing(Time.seconds(elapsed), Time.seconds(cpu), Time.seconds(gc)))
   1.197 +        case _ => None
   1.198 +      }
   1.199 +  }
   1.200 +
   1.201 +
   1.202 +  /* toplevel */
   1.203 +
   1.204 +  val SUBGOALS = "subgoals"
   1.205 +  val PROOF_STATE = "proof_state"
   1.206 +
   1.207 +  val STATE = "state"
   1.208 +  val SUBGOAL = "subgoal"
   1.209 +  val SENDBACK = "sendback"
   1.210 +  val INTENSIFY = "intensify"
   1.211 +
   1.212 +
   1.213 +  /* command status */
   1.214 +
   1.215 +  val TASK = "task"
   1.216 +
   1.217 +  val ACCEPTED = "accepted"
   1.218 +  val FORKED = "forked"
   1.219 +  val JOINED = "joined"
   1.220 +  val RUNNING = "running"
   1.221 +  val FINISHED = "finished"
   1.222 +  val FAILED = "failed"
   1.223 +
   1.224 +
   1.225 +  /* interactive documents */
   1.226 +
   1.227 +  val VERSION = "version"
   1.228 +  val ASSIGN = "assign"
   1.229 +
   1.230 +
   1.231 +  /* prover process */
   1.232 +
   1.233 +  val PROVER_COMMAND = "prover_command"
   1.234 +  val PROVER_ARG = "prover_arg"
   1.235 +
   1.236 +
   1.237 +  /* messages */
   1.238 +
   1.239 +  val Serial = new Properties.Long("serial")
   1.240 +
   1.241 +  val MESSAGE = "message"
   1.242 +
   1.243 +  val INIT = "init"
   1.244 +  val STATUS = "status"
   1.245 +  val REPORT = "report"
   1.246 +  val WRITELN = "writeln"
   1.247 +  val TRACING = "tracing"
   1.248 +  val WARNING = "warning"
   1.249 +  val ERROR = "error"
   1.250 +  val PROTOCOL = "protocol"
   1.251 +  val SYSTEM = "system"
   1.252 +  val STDOUT = "stdout"
   1.253 +  val STDERR = "stderr"
   1.254 +  val EXIT = "exit"
   1.255 +
   1.256 +  val WRITELN_MESSAGE = "writeln_message"
   1.257 +  val TRACING_MESSAGE = "tracing_message"
   1.258 +  val WARNING_MESSAGE = "warning_message"
   1.259 +  val ERROR_MESSAGE = "error_message"
   1.260 +
   1.261 +  val message: String => String =
   1.262 +    Map(WRITELN -> WRITELN_MESSAGE, TRACING -> TRACING_MESSAGE,
   1.263 +        WARNING -> WARNING_MESSAGE, ERROR -> ERROR_MESSAGE)
   1.264 +      .withDefault((name: String) => name + "_message")
   1.265 +
   1.266 +  val Return_Code = new Properties.Int("return_code")
   1.267 +
   1.268 +  val LEGACY = "legacy"
   1.269 +
   1.270 +  val NO_REPORT = "no_report"
   1.271 +
   1.272 +  val BAD = "bad"
   1.273 +
   1.274 +  val GRAPHVIEW = "graphview"
   1.275 +
   1.276 +
   1.277 +  /* protocol message functions */
   1.278 +
   1.279 +  val FUNCTION = "function"
   1.280 +  val Function = new Properties.String(FUNCTION)
   1.281 +
   1.282 +  val Assign_Execs: Properties.T = List((FUNCTION, "assign_execs"))
   1.283 +  val Removed_Versions: Properties.T = List((FUNCTION, "removed_versions"))
   1.284 +
   1.285 +  object Invoke_Scala
   1.286 +  {
   1.287 +    def unapply(props: Properties.T): Option[(String, String)] =
   1.288 +      props match {
   1.289 +        case List((FUNCTION, "invoke_scala"), (NAME, name), (ID, id)) => Some((name, id))
   1.290 +        case _ => None
   1.291 +      }
   1.292 +  }
   1.293 +  object Cancel_Scala
   1.294 +  {
   1.295 +    def unapply(props: Properties.T): Option[String] =
   1.296 +      props match {
   1.297 +        case List((FUNCTION, "cancel_scala"), (ID, id)) => Some(id)
   1.298 +        case _ => None
   1.299 +      }
   1.300 +  }
   1.301  }
   1.302  
   1.303