src/Pure/Isar/method.ML
changeset 20030 e62913ef9d24
parent 19778 f0a318495ca4
child 20117 0f7b7bfae82b
equal deleted inserted replaced
20029:16957e34cfab 20030:e62913ef9d24
    56   val tactic: string -> ProofContext.context -> method
    56   val tactic: string -> ProofContext.context -> method
    57   type src
    57   type src
    58   datatype text =
    58   datatype text =
    59     Basic of (ProofContext.context -> method) |
    59     Basic of (ProofContext.context -> method) |
    60     Source of src |
    60     Source of src |
       
    61     Source_i of src |
    61     Then of text list |
    62     Then of text list |
    62     Orelse of text list |
    63     Orelse of text list |
    63     Try of text |
    64     Try of text |
    64     Repeat1 of text |
    65     Repeat1 of text |
    65     SelectGoals of int * text
    66     SelectGoals of int * text
    70   val done_text: text
    71   val done_text: text
    71   val sorry_text: bool -> text
    72   val sorry_text: bool -> text
    72   val finish_text: text option * bool -> text
    73   val finish_text: text option * bool -> text
    73   exception METHOD_FAIL of (string * Position.T) * exn
    74   exception METHOD_FAIL of (string * Position.T) * exn
    74   val method: theory -> src -> ProofContext.context -> method
    75   val method: theory -> src -> ProofContext.context -> method
       
    76   val method_i: theory -> src -> ProofContext.context -> method
    75   val add_methods: (bstring * (src -> ProofContext.context -> method) * string) list
    77   val add_methods: (bstring * (src -> ProofContext.context -> method) * string) list
    76     -> theory -> theory
    78     -> theory -> theory
    77   val add_method: bstring * (src -> ProofContext.context -> method) * string
    79   val add_method: bstring * (src -> ProofContext.context -> method) * string
    78     -> theory -> theory
    80     -> theory -> theory
    79   val method_setup: bstring * string * string -> theory -> theory
    81   val method_setup: bstring * string * string -> theory -> theory
   502 type src = Args.src;
   504 type src = Args.src;
   503 
   505 
   504 datatype text =
   506 datatype text =
   505   Basic of (ProofContext.context -> method) |
   507   Basic of (ProofContext.context -> method) |
   506   Source of src |
   508   Source of src |
       
   509   Source_i of src |
   507   Then of text list |
   510   Then of text list |
   508   Orelse of text list |
   511   Orelse of text list |
   509   Try of text |
   512   Try of text |
   510   Repeat1 of text |
   513   Repeat1 of text |
   511   SelectGoals of int * text;
   514   SelectGoals of int * text;
   550 
   553 
   551 (* get methods *)
   554 (* get methods *)
   552 
   555 
   553 exception METHOD_FAIL of (string * Position.T) * exn;
   556 exception METHOD_FAIL of (string * Position.T) * exn;
   554 
   557 
   555 fun method thy =
   558 fun method_i thy =
   556   let
   559   let
   557     val (space, meths) = MethodsData.get thy;
   560     val meths = #2 (MethodsData.get thy);
   558     fun meth src =
   561     fun meth src =
   559       let
   562       let val ((name, _), pos) = Args.dest_src src in
   560         val ((raw_name, _), pos) = Args.dest_src src;
       
   561         val name = NameSpace.intern space raw_name;
       
   562       in
       
   563         (case Symtab.lookup meths name of
   563         (case Symtab.lookup meths name of
   564           NONE => error ("Unknown proof method: " ^ quote name ^ Position.str_of pos)
   564           NONE => error ("Unknown proof method: " ^ quote name ^ Position.str_of pos)
   565         | SOME ((mth, _), _) => transform_failure (curry METHOD_FAIL (name, pos)) (mth src))
   565         | SOME ((mth, _), _) => transform_failure (curry METHOD_FAIL (name, pos)) (mth src))
   566       end;
   566       end;
   567   in meth end;
   567   in meth end;
       
   568 
       
   569 fun method thy = method_i thy o Args.map_name (NameSpace.intern (#1 (MethodsData.get thy)));
   568 
   570 
   569 
   571 
   570 (* add method *)
   572 (* add method *)
   571 
   573 
   572 fun add_methods raw_meths thy =
   574 fun add_methods raw_meths thy =