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