and expr =
| EGoal of loc * goal
| ECall of loc * id * expr list
+ | ETactic of loc * id * expr list
| EVar of loc * id
| EList of loc * expr list
| ESubsts of loc * substs
and print_pattern fp = function
| PTactic (loc, name, params) ->
- fprintf fp "%s (" name;
+ fprintf fp "*%s (" name;
iter_with_commas fp print_substs params;
fprintf fp ")"
| PVar (loc, id) -> print_id fp id
fprintf fp "%s (" name;
iter_with_commas fp print_expr params;
fprintf fp ")"
+ | ETactic (loc, name, params) ->
+ fprintf fp "*%s (" name;
+ iter_with_commas fp print_expr params;
+ fprintf fp ")"
| EVar (loc, var) -> print_id fp var
| EList (loc, xs) ->
fprintf fp "[";
and expr =
(** goal (params) = patterns : exprs = code *)
| EGoal of loc * goal
- (** goalname (params), tactic (params) etc. *)
+ (** goalname (params) etc. *)
| ECall of loc * id * expr list
- (** variable *)
+ (** *tactic (params) etc. *)
+ | ETactic of loc * id * expr list
+ (** variable, or goal call with no parameters *)
| EVar of loc * id
(** list *)
| EList of loc * expr list
and evaluate_target env = function
| Ast.EGoal _ -> assert false
- (* This could be an instruction to call a goal, or it
- * could be a tactic.
- *)
- | Ast.ECall (loc, "file", [filename]) (* XXX define tactics! *) ->
- (* All parameters of tactics must be simple expressions (strings,
- * in future booleans, numbers, etc).
- *)
- let args = [filename] in
- let args = List.map (simplify env) args in
- run_goal_for_tactic loc env "file" args
-
- | Ast.ECall (loc, "file", _) ->
- failwithf "%a: file tactic called with wrong number of parameters"
- Ast.string_loc loc
-
+ (* Call a goal. *)
| Ast.ECall (loc, name, args) ->
let expr =
try Ast.StringMap.find name env
Ast.string_loc loc name in
run_goal loc env name args goal
+ | Ast.ETactic (loc, name, args) ->
+ (* All parameters of tactics must be simple expressions (strings,
+ * in future booleans, numbers, etc).
+ *)
+ let args = List.map (simplify env) args in
+ run_goal_for_tactic loc env name args
+
(* Look up the variable and substitute it. *)
| Ast.EVar (loc, name) ->
let expr =
| Ast.EList (loc, exprs) ->
evaluate_targets env exprs
- (* A string (with or without substitutions) implies file (filename). *)
+ (* A string (with or without substitutions) implies *file(filename). *)
| Ast.ESubsts (loc, str) ->
let str = substitute loc env str in
run_goal_for_tactic loc env "file" [Ast.CString str]
Ast.string_loc loc
| Ast.ECall (loc, name, _) ->
- failwithf "%a: cannot use goal or tactic ‘%s’ in constant expression"
+ failwithf "%a: cannot use goal ‘%s’ in constant expression"
+ Ast.string_loc loc name
+
+ | Ast.ETactic (loc, name, _) ->
+ failwithf "%a: cannot use tactic ‘*%s’ in constant expression"
Ast.string_loc loc name
| Ast.EGoal (loc, _) ->
%token <Ast.substs> CODE
%token COLON
%token COMMA
-%token <string> ID
%token EQUALS
%token EOF
%token GOAL
+%token <string> ID
%token LEFT_ARRAY
%token LEFT_PAREN
%token LET
%token RIGHT_ARRAY
%token RIGHT_PAREN
%token <Ast.substs> STRING
+%token <string> TACTIC
(* Start nonterminals. *)
%start <Ast.env> file
expr:
| ID params { Ast.ECall ($loc, $1, $2) }
| ID { Ast.EVar ($loc, $1) }
+ | TACTIC params { Ast.ETactic ($loc, $1, $2) }
| STRING { Ast.ESubsts ($loc, $1) }
| LEFT_ARRAY barelist RIGHT_ARRAY { Ast.EList ($loc, $2) }
;