added ML antiquotation @{keyword};
authorwenzelm
Thu, 15 Mar 2012 19:48:19 +0100
changeset 46948 aae5566d6756
parent 46947 b8c7eb0c2f89
child 46949 94aa7b81bcf6
added ML antiquotation @{keyword};
NEWS
src/Pure/ML/ml_antiquote.ML
--- a/NEWS	Thu Mar 15 19:02:34 2012 +0100
+++ b/NEWS	Thu Mar 15 19:48:19 2012 +0100
@@ -371,6 +371,9 @@
 
 *** ML ***
 
+* Antiquotation @{keyword "name"} produces a parser for outer syntax
+from a minor keyword introduced via theory header declaration.
+
 * Local_Theory.define no longer hard-wires default theorem name
 "foo_def": definitional packages need to make this explicit, and may
 choose to omit theorem bindings for definitions by using
--- a/src/Pure/ML/ml_antiquote.ML	Thu Mar 15 19:02:34 2012 +0100
+++ b/src/Pure/ML/ml_antiquote.ML	Thu Mar 15 19:48:19 2012 +0100
@@ -182,5 +182,16 @@
           val const = Const (c, Consts.instance (Proof_Context.consts_of ctxt) (c, Ts));
         in ML_Syntax.atomic (ML_Syntax.print_term const) end))));
 
+
+(* outer syntax *)
+
+val _ = Context.>> (Context.map_theory
+  (value (Binding.name "keyword")
+    (Args.theory -- Scan.lift (Parse.position Parse.string) >> (fn (thy, (name, pos)) =>
+      (if is_none (Thy_Header.the_keyword thy name) then
+        ML_Syntax.atomic ("Parse.$$$ " ^ ML_Syntax.print_string name)
+       else error ("Unknown minor keyword " ^ quote name))
+      handle ERROR msg => error (msg ^ Position.str_of pos)))));
+
 end;