src/Pure/Isar/args.ML
changeset 8233 85169951d515
parent 8089 8efec140c5e4
child 8282 58a33fd5b30c
equal deleted inserted replaced
8232:6b19ee96546c 8233:85169951d515
    31   val global_prop: theory * T list -> term * (theory * T list)
    31   val global_prop: theory * T list -> term * (theory * T list)
    32   val local_typ: Proof.context * T list -> typ * (Proof.context * T list)
    32   val local_typ: Proof.context * T list -> typ * (Proof.context * T list)
    33   val local_term: Proof.context * T list -> term * (Proof.context * T list)
    33   val local_term: Proof.context * T list -> term * (Proof.context * T list)
    34   val local_prop: Proof.context * T list -> term * (Proof.context * T list)
    34   val local_prop: Proof.context * T list -> term * (Proof.context * T list)
    35   val bang_facts: Proof.context * T list -> thm list * (Proof.context * T list)
    35   val bang_facts: Proof.context * T list -> thm list * (Proof.context * T list)
       
    36   val goal_spec: T list -> ((int -> tactic) -> tactic) * T list
    36   type src
    37   type src
    37   val src: (string * T list) * Position.T -> src
    38   val src: (string * T list) * Position.T -> src
    38   val dest_src: src -> (string * T list) * Position.T
    39   val dest_src: src -> (string * T list) * Position.T
    39   val attribs: T list -> src list * T list
    40   val attribs: T list -> src list * T list
    40   val opt_attribs: T list -> src list * T list
    41   val opt_attribs: T list -> src list * T list
   100 fun $$$$ x = Scan.one (fn Arg (k, (y, _)) => (k = Ident orelse k = Keyword) andalso x = y);
   101 fun $$$$ x = Scan.one (fn Arg (k, (y, _)) => (k = Ident orelse k = Keyword) andalso x = y);
   101 fun $$$ x = $$$$ x >> val_of;
   102 fun $$$ x = $$$$ x >> val_of;
   102 
   103 
   103 val name = Scan.one (fn Arg (k, (x, _)) => k = Ident orelse k = String) >> val_of;
   104 val name = Scan.one (fn Arg (k, (x, _)) => k = Ident orelse k = String) >> val_of;
   104 
   105 
       
   106 val keyword_symid =
       
   107   Scan.one (fn Arg (k, (x, _)) => k = Keyword andalso OuterLex.is_sid x) >> val_of;
       
   108 
   105 fun kind f = Scan.one (K true) :--
   109 fun kind f = Scan.one (K true) :--
   106   (fn Arg (Ident, (x, _)) =>
   110   (fn Arg (Ident, (x, _)) =>
   107     (case f x of Some y => Scan.succeed y | _ => Scan.fail)
   111     (case f x of Some y => Scan.succeed y | _ => Scan.fail)
   108   | _ => Scan.fail) >> #2;
   112   | _ => Scan.fail) >> #2;
   109 
   113 
   135 
   139 
   136 (* bang facts *)
   140 (* bang facts *)
   137 
   141 
   138 val bang_facts = Scan.depend (fn ctxt =>
   142 val bang_facts = Scan.depend (fn ctxt =>
   139   ($$$ "!" >> K (ProofContext.prems_of ctxt) || Scan.succeed []) >> pair ctxt);
   143   ($$$ "!" >> K (ProofContext.prems_of ctxt) || Scan.succeed []) >> pair ctxt);
       
   144 
       
   145 
       
   146 (* goal specifier *)
       
   147 
       
   148 val tactical = $$$$ "!" >> K ALLGOALS || $$$$ "?" >> K FINDGOAL || nat >> curry op |>;
       
   149 val goal_spec = $$$$ "(" |-- tactical --| $$$$ ")";
   140 
   150 
   141 
   151 
   142 (* args *)
   152 (* args *)
   143 
   153 
   144 val exclude = explode "(){}[],";
   154 val exclude = explode "(){}[],";
   183 (* attribs *)
   193 (* attribs *)
   184 
   194 
   185 fun list1 scan = scan -- Scan.repeat ($$$ "," |-- scan) >> op ::;
   195 fun list1 scan = scan -- Scan.repeat ($$$ "," |-- scan) >> op ::;
   186 fun list scan = list1 scan || Scan.succeed [];
   196 fun list scan = list1 scan || Scan.succeed [];
   187 
   197 
   188 val attrib = position (name -- !!! (args false)) >> src;
   198 val attrib = position ((keyword_symid || name) -- !!! (args false)) >> src;
   189 val attribs = $$$ "[" |-- !!! (list attrib --| $$$ "]");
   199 val attribs = $$$ "[" |-- !!! (list attrib --| $$$ "]");
   190 val opt_attribs = Scan.optional attribs [];
   200 val opt_attribs = Scan.optional attribs [];
   191 
   201 
   192 
   202 
   193 end;
   203 end;