src/Pure/PIDE/isabelle_markup.ML
author wenzelm
Tue Sep 25 22:36:06 2012 +0200 (2012-09-25 ago)
changeset 49566 66cbf8bb4693
parent 49554 7b7bd2d7661d
child 49674 dbadb4d03cbc
permissions -rw-r--r--
basic integration of graphview into document model;
added Graph_Dockable;
updated Isabelle/jEdit authors and dependencies etc.;
     1 (*  Title:      Pure/PIDE/isabelle_markup.ML
     2     Author:     Makarius
     3 
     4 Isabelle markup elements.
     5 *)
     6 
     7 signature ISABELLE_MARKUP =
     8 sig
     9   val bindingN: string val binding: Markup.T
    10   val entityN: string val entity: string -> string -> Markup.T
    11   val get_entity_kind: Markup.T -> string option
    12   val defN: string
    13   val refN: string
    14   val lineN: string
    15   val offsetN: string
    16   val end_offsetN: string
    17   val fileN: string
    18   val idN: string
    19   val position_properties': string list
    20   val position_properties: string list
    21   val positionN: string val position: Markup.T
    22   val pathN: string val path: string -> Markup.T
    23   val indentN: string
    24   val blockN: string val block: int -> Markup.T
    25   val widthN: string
    26   val breakN: string val break: int -> Markup.T
    27   val fbreakN: string val fbreak: Markup.T
    28   val hiddenN: string val hidden: Markup.T
    29   val theoryN: string
    30   val classN: string
    31   val type_nameN: string
    32   val constantN: string
    33   val fixedN: string val fixed: string -> Markup.T
    34   val dynamic_factN: string val dynamic_fact: string -> Markup.T
    35   val tfreeN: string val tfree: Markup.T
    36   val tvarN: string val tvar: Markup.T
    37   val freeN: string val free: Markup.T
    38   val skolemN: string val skolem: Markup.T
    39   val boundN: string val bound: Markup.T
    40   val varN: string val var: Markup.T
    41   val numeralN: string val numeral: Markup.T
    42   val literalN: string val literal: Markup.T
    43   val delimiterN: string val delimiter: Markup.T
    44   val inner_stringN: string val inner_string: Markup.T
    45   val inner_commentN: string val inner_comment: Markup.T
    46   val token_rangeN: string val token_range: Markup.T
    47   val sortN: string val sort: Markup.T
    48   val typN: string val typ: Markup.T
    49   val termN: string val term: Markup.T
    50   val propN: string val prop: Markup.T
    51   val typingN: string val typing: Markup.T
    52   val ML_keywordN: string val ML_keyword: Markup.T
    53   val ML_delimiterN: string val ML_delimiter: Markup.T
    54   val ML_tvarN: string val ML_tvar: Markup.T
    55   val ML_numeralN: string val ML_numeral: Markup.T
    56   val ML_charN: string val ML_char: Markup.T
    57   val ML_stringN: string val ML_string: Markup.T
    58   val ML_commentN: string val ML_comment: Markup.T
    59   val ML_defN: string
    60   val ML_openN: string
    61   val ML_structN: string
    62   val ML_typingN: string val ML_typing: Markup.T
    63   val ML_sourceN: string val ML_source: Markup.T
    64   val doc_sourceN: string val doc_source: Markup.T
    65   val antiqN: string val antiq: Markup.T
    66   val ML_antiquotationN: string
    67   val document_antiquotationN: string
    68   val document_antiquotation_optionN: string
    69   val keywordN: string val keyword: Markup.T
    70   val operatorN: string val operator: Markup.T
    71   val commandN: string val command: Markup.T
    72   val stringN: string val string: Markup.T
    73   val altstringN: string val altstring: Markup.T
    74   val verbatimN: string val verbatim: Markup.T
    75   val commentN: string val comment: Markup.T
    76   val controlN: string val control: Markup.T
    77   val tokenN: string val token: Properties.T -> Markup.T
    78   val keyword1N: string val keyword1: Markup.T
    79   val keyword2N: string val keyword2: Markup.T
    80   val elapsedN: string
    81   val cpuN: string
    82   val gcN: string
    83   val timingN: string val timing: Timing.timing -> Markup.T
    84   val subgoalsN: string
    85   val proof_stateN: string val proof_state: int -> Markup.T
    86   val stateN: string val state: Markup.T
    87   val subgoalN: string val subgoal: Markup.T
    88   val sendbackN: string val sendback: Markup.T
    89   val intensifyN: string val intensify: Markup.T
    90   val taskN: string
    91   val acceptedN: string val accepted: Markup.T
    92   val forkedN: string val forked: Markup.T
    93   val joinedN: string val joined: Markup.T
    94   val runningN: string val running: Markup.T
    95   val finishedN: string val finished: Markup.T
    96   val failedN: string val failed: Markup.T
    97   val serialN: string
    98   val legacyN: string val legacy: Markup.T
    99   val promptN: string val prompt: Markup.T
   100   val reportN: string val report: Markup.T
   101   val no_reportN: string val no_report: Markup.T
   102   val badN: string val bad: Markup.T
   103   val graphviewN: string
   104   val functionN: string
   105   val assign_execs: Properties.T
   106   val removed_versions: Properties.T
   107   val invoke_scala: string -> string -> Properties.T
   108   val cancel_scala: string -> Properties.T
   109 end;
   110 
   111 structure Isabelle_Markup: ISABELLE_MARKUP =
   112 struct
   113 
   114 (** markup elements **)
   115 
   116 fun markup_elem elem = (elem, (elem, []): Markup.T);
   117 fun markup_string elem prop = (elem, fn s => (elem, [(prop, s)]): Markup.T);
   118 fun markup_int elem prop = (elem, fn i => (elem, [(prop, Markup.print_int i)]): Markup.T);
   119 
   120 
   121 (* formal entities *)
   122 
   123 val (bindingN, binding) = markup_elem "binding";
   124 
   125 val entityN = "entity";
   126 fun entity kind name = (entityN, [(Markup.nameN, name), (Markup.kindN, kind)]);
   127 
   128 fun get_entity_kind (name, props) =
   129   if name = entityN then AList.lookup (op =) props Markup.kindN
   130   else NONE;
   131 
   132 val defN = "def";
   133 val refN = "ref";
   134 
   135 
   136 (* position *)
   137 
   138 val lineN = "line";
   139 val offsetN = "offset";
   140 val end_offsetN = "end_offset";
   141 val fileN = "file";
   142 val idN = "id";
   143 
   144 val position_properties' = [fileN, idN];
   145 val position_properties = [lineN, offsetN, end_offsetN] @ position_properties';
   146 
   147 val (positionN, position) = markup_elem "position";
   148 
   149 
   150 (* path *)
   151 
   152 val (pathN, path) = markup_string "path" Markup.nameN;
   153 
   154 
   155 (* pretty printing *)
   156 
   157 val indentN = "indent";
   158 val (blockN, block) = markup_int "block" indentN;
   159 
   160 val widthN = "width";
   161 val (breakN, break) = markup_int "break" widthN;
   162 
   163 val (fbreakN, fbreak) = markup_elem "fbreak";
   164 
   165 
   166 (* hidden text *)
   167 
   168 val (hiddenN, hidden) = markup_elem "hidden";
   169 
   170 
   171 (* logical entities *)
   172 
   173 val theoryN = "theory";
   174 val classN = "class";
   175 val type_nameN = "type_name";
   176 val constantN = "constant";
   177 
   178 val (fixedN, fixed) = markup_string "fixed" Markup.nameN;
   179 val (dynamic_factN, dynamic_fact) = markup_string "dynamic_fact" Markup.nameN;
   180 
   181 
   182 (* inner syntax *)
   183 
   184 val (tfreeN, tfree) = markup_elem "tfree";
   185 val (tvarN, tvar) = markup_elem "tvar";
   186 val (freeN, free) = markup_elem "free";
   187 val (skolemN, skolem) = markup_elem "skolem";
   188 val (boundN, bound) = markup_elem "bound";
   189 val (varN, var) = markup_elem "var";
   190 val (numeralN, numeral) = markup_elem "numeral";
   191 val (literalN, literal) = markup_elem "literal";
   192 val (delimiterN, delimiter) = markup_elem "delimiter";
   193 val (inner_stringN, inner_string) = markup_elem "inner_string";
   194 val (inner_commentN, inner_comment) = markup_elem "inner_comment";
   195 
   196 val (token_rangeN, token_range) = markup_elem "token_range";
   197 
   198 val (sortN, sort) = markup_elem "sort";
   199 val (typN, typ) = markup_elem "typ";
   200 val (termN, term) = markup_elem "term";
   201 val (propN, prop) = markup_elem "prop";
   202 
   203 val (typingN, typing) = markup_elem "typing";
   204 
   205 
   206 (* ML syntax *)
   207 
   208 val (ML_keywordN, ML_keyword) = markup_elem "ML_keyword";
   209 val (ML_delimiterN, ML_delimiter) = markup_elem "ML_delimiter";
   210 val (ML_tvarN, ML_tvar) = markup_elem "ML_tvar";
   211 val (ML_numeralN, ML_numeral) = markup_elem "ML_numeral";
   212 val (ML_charN, ML_char) = markup_elem "ML_char";
   213 val (ML_stringN, ML_string) = markup_elem "ML_string";
   214 val (ML_commentN, ML_comment) = markup_elem "ML_comment";
   215 
   216 val ML_defN = "ML_def";
   217 val ML_openN = "ML_open";
   218 val ML_structN = "ML_struct";
   219 val (ML_typingN, ML_typing) = markup_elem "ML_typing";
   220 
   221 
   222 (* embedded source text *)
   223 
   224 val (ML_sourceN, ML_source) = markup_elem "ML_source";
   225 val (doc_sourceN, doc_source) = markup_elem "doc_source";
   226 
   227 val (antiqN, antiq) = markup_elem "antiq";
   228 val ML_antiquotationN = "ML_antiquotation";
   229 val document_antiquotationN = "document_antiquotation";
   230 val document_antiquotation_optionN = "document_antiquotation_option";
   231 
   232 
   233 (* outer syntax *)
   234 
   235 val (keywordN, keyword) = markup_elem "keyword";
   236 val (operatorN, operator) = markup_elem "operator";
   237 val (commandN, command) = markup_elem "command";
   238 val (stringN, string) = markup_elem "string";
   239 val (altstringN, altstring) = markup_elem "altstring";
   240 val (verbatimN, verbatim) = markup_elem "verbatim";
   241 val (commentN, comment) = markup_elem "comment";
   242 val (controlN, control) = markup_elem "control";
   243 
   244 val tokenN = "token";
   245 fun token props = (tokenN, props);
   246 
   247 val (keyword1N, keyword1) = markup_elem "keyword1";
   248 val (keyword2N, keyword2) = markup_elem "keyword2";
   249 
   250 
   251 (* timing *)
   252 
   253 val timingN = "timing";
   254 val elapsedN = "elapsed";
   255 val cpuN = "cpu";
   256 val gcN = "gc";
   257 
   258 fun timing {elapsed, cpu, gc} =
   259   (timingN,
   260    [(elapsedN, Time.toString elapsed),
   261     (cpuN, Time.toString cpu),
   262     (gcN, Time.toString gc)]);
   263 
   264 
   265 (* toplevel *)
   266 
   267 val subgoalsN = "subgoals";
   268 val (proof_stateN, proof_state) = markup_int "proof_state" subgoalsN;
   269 
   270 val (stateN, state) = markup_elem "state";
   271 val (subgoalN, subgoal) = markup_elem "subgoal";
   272 val (sendbackN, sendback) = markup_elem "sendback";
   273 val (intensifyN, intensify) = markup_elem "intensify";
   274 
   275 
   276 (* command status *)
   277 
   278 val taskN = "task";
   279 
   280 val (acceptedN, accepted) = markup_elem "accepted";
   281 val (forkedN, forked) = markup_elem "forked";
   282 val (joinedN, joined) = markup_elem "joined";
   283 val (runningN, running) = markup_elem "running";
   284 val (finishedN, finished) = markup_elem "finished";
   285 val (failedN, failed) = markup_elem "failed";
   286 
   287 
   288 (* messages *)
   289 
   290 val serialN = "serial";
   291 
   292 val (legacyN, legacy) = markup_elem "legacy";
   293 val (promptN, prompt) = markup_elem "prompt";
   294 
   295 val (reportN, report) = markup_elem "report";
   296 val (no_reportN, no_report) = markup_elem "no_report";
   297 
   298 val (badN, bad) = markup_elem "bad";
   299 
   300 val graphviewN = "graphview";
   301 
   302 
   303 (* protocol message functions *)
   304 
   305 val functionN = "function"
   306 
   307 val assign_execs = [(functionN, "assign_execs")];
   308 val removed_versions = [(functionN, "removed_versions")];
   309 
   310 fun invoke_scala name id = [(functionN, "invoke_scala"), (Markup.nameN, name), (idN, id)];
   311 fun cancel_scala id = [(functionN, "cancel_scala"), (idN, id)];
   312 
   313 end;