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