support for declaration within token source;
authorwenzelm
Wed, 20 Aug 2014 17:23:47 +0200
changeset 58017 5bdb58845eab
parent 58016 28e5ccf4a27f
child 58018 beb4b7c0bb30
support for declaration within token source;
src/Pure/Isar/args.ML
src/Pure/Isar/token.ML
--- a/src/Pure/Isar/args.ML	Wed Aug 20 16:06:10 2014 +0200
+++ b/src/Pure/Isar/args.ML	Wed Aug 20 17:23:47 2014 +0200
@@ -39,12 +39,14 @@
   val internal_term: term parser
   val internal_fact: thm list parser
   val internal_attribute: (morphism -> attribute) parser
+  val internal_declaration: declaration parser
   val named_source: (Token.T -> Token.src) -> Token.src parser
   val named_typ: (string -> typ) -> typ parser
   val named_term: (string -> term) -> term parser
   val named_fact: (string -> string option * thm list) -> thm list parser
-  val named_attribute:
-    (string * Position.T -> morphism -> attribute) -> (morphism -> attribute) parser
+  val named_attribute: (string * Position.T -> morphism -> attribute) ->
+    (morphism -> attribute) parser
+  val text_declaration: (Symbol_Pos.source -> declaration) -> declaration parser
   val typ_abbrev: typ context_parser
   val typ: typ context_parser
   val term: term context_parser
@@ -137,6 +139,7 @@
 val internal_term = value (fn Token.Term t => t);
 val internal_fact = value (fn Token.Fact (_, ths) => ths);
 val internal_attribute = value (fn Token.Attribute att => att);
+val internal_declaration = value (fn Token.Declaration decl => decl);
 
 fun named_source read = internal_source || named >> evaluate Token.Source read;
 
@@ -152,6 +155,10 @@
   internal_attribute ||
   named >> evaluate Token.Attribute (fn tok => att (Token.content_of tok, Token.pos_of tok));
 
+fun text_declaration read =
+  internal_declaration ||
+  text_token >> evaluate Token.Declaration (read o Token.source_position_of);
+
 
 (* terms and types *)
 
--- a/src/Pure/Isar/token.ML	Wed Aug 20 16:06:10 2014 +0200
+++ b/src/Pure/Isar/token.ML	Wed Aug 20 17:23:47 2014 +0200
@@ -22,6 +22,7 @@
     Term of term |
     Fact of string option * thm list |
     Attribute of morphism -> attribute |
+    Declaration of declaration |
     Files of file Exn.result list
   val name0: string -> value
   val pos_of: T -> Position.T
@@ -163,6 +164,7 @@
   Term of term |
   Fact of string option * thm list |  (*optional name for dynamic fact, i.e. fact "variable"*)
   Attribute of morphism -> attribute |
+  Declaration of declaration |
   Files of file Exn.result list;
 
 fun name0 a = Name (a, Morphism.identity);
@@ -421,6 +423,7 @@
     | Term t => Term (Morphism.term phi t)
     | Fact (a, ths) => Fact (a, Morphism.fact phi ths)
     | Attribute att => Attribute (Morphism.transform phi att)
+    | Declaration decl => Declaration (Morphism.transform phi decl)
     | Files _ => v))
 and transform_src phi = map_args (transform phi);