From 8d9aa27f1bf7a0a99a66924ba10fd24a0d691163 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 27 Dec 2019 19:47:16 +0000 Subject: [PATCH] Substitute %<, %@ etc variables into code. --- src/eval.ml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/eval.ml b/src/eval.ml index f03e0e4..74873e5 100644 --- a/src/eval.ml +++ b/src/eval.ml @@ -79,7 +79,22 @@ and run_goal env loc name args (params, patterns, deps, code) = (match code with | None -> () | Some code -> - let code = Ast.substitute env loc code in + (* Add some standard variables to the environment. *) + let expr_of_substs s = Ast.ESubsts (Ast.noloc, s) in + let expr_of_pattern = function + | Ast.PTactic (loc, tactic, targs) -> + Ast.ETactic (loc, tactic, List.map expr_of_substs targs) + | Ast.PVar (loc, name) -> + Ast.EVar (loc, name) + in + let pexprs = List.map expr_of_pattern patterns in + let env = Ast.Env.add "@" (Ast.EList (Ast.noloc, pexprs)) env in + let env = Ast.Env.add "<" (Ast.EList (Ast.noloc, deps)) env in + let env = + match deps with + | [] -> env + | d :: _ -> Ast.Env.add "^" d env in + let code = Ast.to_shell_script env loc code in Printf.printf "running : %s\n" code ); -- 1.8.3.1