src/Pure/PIDE/isabelle_markup.ML
author wenzelm
Wed Sep 12 13:21:33 2012 +0200 (2012-09-12 ago)
changeset 49321 a48f9bbbe720
parent 49036 4680c4046814
child 49358 0fa351b1bd14
permissions -rw-r--r--
avoid spaces in markup names, which might cause problems in boundary situations (e.g. HTML class);
     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 elapsedN: string
    79   val cpuN: string
    80   val gcN: string
    81   val timingN: string val timing: Timing.timing -> Markup.T
    82   val subgoalsN: string
    83   val proof_stateN: string val proof_state: int -> Markup.T
    84   val stateN: string val state: Markup.T
    85   val subgoalN: string val subgoal: Markup.T
    86   val sendbackN: string val sendback: Markup.T
    87   val hiliteN: string val hilite: Markup.T
    88   val taskN: string
    89   val acceptedN: string val accepted: Markup.T
    90   val forkedN: string val forked: Markup.T
    91   val joinedN: string val joined: Markup.T
    92   val runningN: string val running: Markup.T
    93   val finishedN: string val finished: Markup.T
    94   val failedN: string val failed: Markup.T
    95   val serialN: string
    96   val legacyN: string val legacy: Markup.T
    97   val promptN: string val prompt: Markup.T
    98   val reportN: string val report: Markup.T
    99   val no_reportN: string val no_report: Markup.T
   100   val badN: string val bad: Markup.T
   101   val functionN: string
   102   val assign_execs: Properties.T
   103   val removed_versions: Properties.T
   104   val invoke_scala: string -> string -> Properties.T
   105   val cancel_scala: string -> Properties.T
   106 end;
   107 
   108 structure Isabelle_Markup: ISABELLE_MARKUP =
   109 struct
   110 
   111 (** markup elements **)
   112 
   113 fun markup_elem elem = (elem, (elem, []): Markup.T);
   114 fun markup_string elem prop = (elem, fn s => (elem, [(prop, s)]): Markup.T);
   115 fun markup_int elem prop = (elem, fn i => (elem, [(prop, Markup.print_int i)]): Markup.T);
   116 
   117 
   118 (* formal entities *)
   119 
   120 val (bindingN, binding) = markup_elem "binding";
   121 
   122 val entityN = "entity";
   123 fun entity kind name = (entityN, [(Markup.nameN, name), (Markup.kindN, kind)]);
   124 
   125 fun get_entity_kind (name, props) =
   126   if name = entityN then AList.lookup (op =) props Markup.kindN
   127   else NONE;
   128 
   129 val defN = "def";
   130 val refN = "ref";
   131 
   132 
   133 (* position *)
   134 
   135 val lineN = "line";
   136 val offsetN = "offset";
   137 val end_offsetN = "end_offset";
   138 val fileN = "file";
   139 val idN = "id";
   140 
   141 val position_properties' = [fileN, idN];
   142 val position_properties = [lineN, offsetN, end_offsetN] @ position_properties';
   143 
   144 val (positionN, position) = markup_elem "position";
   145 
   146 
   147 (* path *)
   148 
   149 val (pathN, path) = markup_string "path" Markup.nameN;
   150 
   151 
   152 (* pretty printing *)
   153 
   154 val indentN = "indent";
   155 val (blockN, block) = markup_int "block" indentN;
   156 
   157 val widthN = "width";
   158 val (breakN, break) = markup_int "break" widthN;
   159 
   160 val (fbreakN, fbreak) = markup_elem "fbreak";
   161 
   162 
   163 (* hidden text *)
   164 
   165 val (hiddenN, hidden) = markup_elem "hidden";
   166 
   167 
   168 (* logical entities *)
   169 
   170 val theoryN = "theory";
   171 val classN = "class";
   172 val type_nameN = "type_name";
   173 val constantN = "constant";
   174 
   175 val (fixedN, fixed) = markup_string "fixed" Markup.nameN;
   176 val (dynamic_factN, dynamic_fact) = markup_string "dynamic_fact" Markup.nameN;
   177 
   178 
   179 (* inner syntax *)
   180 
   181 val (tfreeN, tfree) = markup_elem "tfree";
   182 val (tvarN, tvar) = markup_elem "tvar";
   183 val (freeN, free) = markup_elem "free";
   184 val (skolemN, skolem) = markup_elem "skolem";
   185 val (boundN, bound) = markup_elem "bound";
   186 val (varN, var) = markup_elem "var";
   187 val (numeralN, numeral) = markup_elem "numeral";
   188 val (literalN, literal) = markup_elem "literal";
   189 val (delimiterN, delimiter) = markup_elem "delimiter";
   190 val (inner_stringN, inner_string) = markup_elem "inner_string";
   191 val (inner_commentN, inner_comment) = markup_elem "inner_comment";
   192 
   193 val (token_rangeN, token_range) = markup_elem "token_range";
   194 
   195 val (sortN, sort) = markup_elem "sort";
   196 val (typN, typ) = markup_elem "typ";
   197 val (termN, term) = markup_elem "term";
   198 val (propN, prop) = markup_elem "prop";
   199 
   200 val (typingN, typing) = markup_elem "typing";
   201 
   202 
   203 (* ML syntax *)
   204 
   205 val (ML_keywordN, ML_keyword) = markup_elem "ML_keyword";
   206 val (ML_delimiterN, ML_delimiter) = markup_elem "ML_delimiter";
   207 val (ML_tvarN, ML_tvar) = markup_elem "ML_tvar";
   208 val (ML_numeralN, ML_numeral) = markup_elem "ML_numeral";
   209 val (ML_charN, ML_char) = markup_elem "ML_char";
   210 val (ML_stringN, ML_string) = markup_elem "ML_string";
   211 val (ML_commentN, ML_comment) = markup_elem "ML_comment";
   212 
   213 val ML_defN = "ML_def";
   214 val ML_openN = "ML_open";
   215 val ML_structN = "ML_struct";
   216 val (ML_typingN, ML_typing) = markup_elem "ML_typing";
   217 
   218 
   219 (* embedded source text *)
   220 
   221 val (ML_sourceN, ML_source) = markup_elem "ML_source";
   222 val (doc_sourceN, doc_source) = markup_elem "doc_source";
   223 
   224 val (antiqN, antiq) = markup_elem "antiq";
   225 val ML_antiquotationN = "ML_antiquotation";
   226 val document_antiquotationN = "document_antiquotation";
   227 val document_antiquotation_optionN = "document_antiquotation_option";
   228 
   229 
   230 (* outer syntax *)
   231 
   232 val (keywordN, keyword) = markup_elem "keyword";
   233 val (operatorN, operator) = markup_elem "operator";
   234 val (commandN, command) = markup_elem "command";
   235 val (stringN, string) = markup_elem "string";
   236 val (altstringN, altstring) = markup_elem "altstring";
   237 val (verbatimN, verbatim) = markup_elem "verbatim";
   238 val (commentN, comment) = markup_elem "comment";
   239 val (controlN, control) = markup_elem "control";
   240 
   241 val tokenN = "token";
   242 fun token props = (tokenN, props);
   243 
   244 
   245 (* timing *)
   246 
   247 val timingN = "timing";
   248 val elapsedN = "elapsed";
   249 val cpuN = "cpu";
   250 val gcN = "gc";
   251 
   252 fun timing {elapsed, cpu, gc} =
   253   (timingN,
   254    [(elapsedN, Time.toString elapsed),
   255     (cpuN, Time.toString cpu),
   256     (gcN, Time.toString gc)]);
   257 
   258 
   259 (* toplevel *)
   260 
   261 val subgoalsN = "subgoals";
   262 val (proof_stateN, proof_state) = markup_int "proof_state" subgoalsN;
   263 
   264 val (stateN, state) = markup_elem "state";
   265 val (subgoalN, subgoal) = markup_elem "subgoal";
   266 val (sendbackN, sendback) = markup_elem "sendback";
   267 val (hiliteN, hilite) = markup_elem "hilite";
   268 
   269 
   270 (* command status *)
   271 
   272 val taskN = "task";
   273 
   274 val (acceptedN, accepted) = markup_elem "accepted";
   275 val (forkedN, forked) = markup_elem "forked";
   276 val (joinedN, joined) = markup_elem "joined";
   277 val (runningN, running) = markup_elem "running";
   278 val (finishedN, finished) = markup_elem "finished";
   279 val (failedN, failed) = markup_elem "failed";
   280 
   281 
   282 (* messages *)
   283 
   284 val serialN = "serial";
   285 
   286 val (legacyN, legacy) = markup_elem "legacy";
   287 val (promptN, prompt) = markup_elem "prompt";
   288 
   289 val (reportN, report) = markup_elem "report";
   290 val (no_reportN, no_report) = markup_elem "no_report";
   291 
   292 val (badN, bad) = markup_elem "bad";
   293 
   294 
   295 (* protocol message functions *)
   296 
   297 val functionN = "function"
   298 
   299 val assign_execs = [(functionN, "assign_execs")];
   300 val removed_versions = [(functionN, "removed_versions")];
   301 
   302 fun invoke_scala name id = [(functionN, "invoke_scala"), (Markup.nameN, name), (idN, id)];
   303 fun cancel_scala id = [(functionN, "cancel_scala"), (idN, id)];
   304 
   305 end;