| NUnfocus of loc
| NTry of loc * ntactic
| NAssumption of loc
+ | NRepeat of loc * ntactic
+ | NBlock of loc * ntactic list
type ('term, 'lazy_term, 'reduction, 'ident) tactic =
(* Higher order tactics (i.e. tacticals) *)
(String.concat " " (List.map string_of_int l))
| NUnfocus _ -> "##unfocus"
| NSkip _ -> "##skip"
- | NTry (_,tac) -> "ntry (" ^ pp_ntactic ~map_unicode_to_tex tac ^ ")"
+ | NTry (_,tac) -> "ntry " ^ pp_ntactic ~map_unicode_to_tex tac
| NAssumption _ -> "nassumption"
+ | NBlock (_,l) ->
+ "(" ^ String.concat " " (List.map (pp_ntactic ~map_unicode_to_tex) l)^ ")"
+ | NRepeat (_,t) -> "nrepeat " ^ pp_ntactic ~map_unicode_to_tex t
;;
let rec pp_tactic ~map_unicode_to_tex ~term_pp ~lazy_term_pp =
| GrafiteAst.Merge _ -> NTactics.merge_tac
;;
-let rec eval_ng_tac (text, prefix_len, tac) =
+let eval_ng_tac tac =
+ let rec aux f (text, prefix_len, tac) =
match tac with
| GrafiteAst.NApply (_loc, t) -> NTactics.apply_tac (text,prefix_len,t)
| GrafiteAst.NAssert (_loc, seqs) ->
| GrafiteAst.NUnfocus _ -> NTactics.unfocus_tac
| GrafiteAst.NWildcard _ -> NTactics.wildcard_tac
| GrafiteAst.NTry (_,tac) -> NTactics.try_tac
- (eval_ng_tac (text, prefix_len, tac))
+ (aux f (text, prefix_len, tac))
| GrafiteAst.NAssumption _ -> NTactics.assumption_tac
+ | GrafiteAst.NBlock (_,l) ->
+ NTactics.block_tac (List.map (fun x -> aux f (text,prefix_len,x)) l)
+ |GrafiteAst.NRepeat (_,tac) ->
+ NTactics.repeat_tac (f f (text, prefix_len, tac))
+ in
+ aux aux tac (* trick for non uniform recursion call *)
;;
let subst_metasenv_and_fix_names status =
G.NReduce (loc, kind, p)
| IDENT "nrewrite"; dir = direction; what = tactic_term ; where = pattern_spec ->
G.NRewrite (loc, dir, what, where)
- | IDENT "ntry"; LPAREN ; tac = SELF ; RPAREN -> G.NTry (loc,tac)
+ | IDENT "ntry"; tac = SELF -> G.NTry (loc,tac)
+ | IDENT "nrepeat"; tac = SELF -> G.NRepeat (loc,tac)
+ | LPAREN; l = LIST1 SELF; RPAREN -> G.NBlock (loc,l)
| IDENT "nassumption" -> G.NAssumption loc
| SYMBOL "#"; n=IDENT -> G.NIntro (loc,n)
| SYMBOL "#"; SYMBOL "_" -> G.NIntro (loc,"_")
List.fold_left (fun status tac -> tac status) status l
;;
+
let compare_statuses ~past ~present =
let _,_,past,_,_ = past#obj in
let _,_,present,_,_ = present#obj in
((status#set_stack stack)#set_obj(sn:>lowtac_status)#obj)#set_estatus sn
;;
-let atomic_tac htac = distribute_tac (exec htac) ;;
+let atomic_tac htac : #tac_status as 'a -> 'a = distribute_tac (exec htac) ;;
+
+let repeat_tac t s =
+ let rec repeat t (status : #tac_status as 'a) : 'a =
+ try repeat t (t status)
+ with NTacStatus.Error _ -> status
+ in
+ atomic_tac (repeat t) s
+;;
+
let try_tac tac status =
try
distribute_tac (auto ~params) status
;;
-let rec repeat_tac t status =
- try repeat_tac t (atomic_tac t status)
- with NTacStatus.Error _ -> status
-;;