let path = inc // filename in
if Sys.file_exists path then path else loop incs
in
- loop Cmdline.includes
+ loop (Cmdline.includes ())
)
let do_include env loc filename optflag file =
%}
(* Tokens. *)
-%token <Ast.substs> CODE
+%token <Ast.code> CODE
%token COLON
%token COMMA
%token EQUALS
%token EOF
+%token EXPRESSION
%token FUNCTION
%token GOAL
%token <string> ID
%token LEFT_PAREN
%token LET
%token OPTINCLUDE
+%token PURE
+%token RETURNING
%token RIGHT_ARRAY
%token RIGHT_PAREN
%token SEMICOLON
%token <Ast.substs> STRING
-%token <string> TACTIC
-%token TACTIC_KEYWORD
+%token STRING_KEYWORD
+%token STRINGS
+%token <string> PRED
+%token PREDICATE
(* Start nonterminals. *)
%start <Ast.expr Ast.Env.t> file
-%start <Ast.expr> expr
+%start <Ast.expr> expr_only
%%
file:
let name, params = $1 in
name, Ast.EGoalDefn ($loc, (params, [], [], Some $2))
}
- | FUNCTION ID params_decl EQUALS CODE
+ | GOAL ID
{
- $2, Ast.EFuncDefn ($loc, ($3, $5))
+ $2, Ast.EGoalDefn ($loc, ([], [], [], None))
}
- | TACTIC_KEYWORD TACTIC params_decl EQUALS CODE
+ | option(PURE) FUNCTION ID params_decl return_decl EQUALS CODE
{
- $2, Ast.ETacticDefn ($loc, ($3, $5))
+ $3, Ast.EFuncDefn ($loc, ($4, $5, $1 <> None, $7))
+ }
+ | PREDICATE PRED params_decl EQUALS CODE
+ {
+ $2, Ast.EPredDefn ($loc, ($3, $5))
}
| LET ID EQUALS expr { $2, $4 }
;
;
param_decl:
| ID { $1 }
+return_decl:
+ | { RetExpr }
+ | RETURNING EXPRESSION { RetExpr }
+ | RETURNING STRINGS { RetStrings }
+ | RETURNING STRING_KEYWORD { RetString }
patterns:
| separated_list(COMMA, pattern) { $1 }
;
pattern:
- | STRING { Ast.PTactic ($loc, "*file", [$1]) }
- | ID pattern_params { Ast.PTactic ($loc, $1, $2) }
+ | STRING { Ast.PPred ($loc, "is-file", [$1]) }
+ | PRED pattern_params { Ast.PPred ($loc, $1, $2) }
;
pattern_params:
| LEFT_PAREN separated_list(COMMA, pattern_param) RIGHT_PAREN { $2 }
expr:
| ID params { Ast.ECall ($loc, $1, $2) }
| ID { Ast.EVar ($loc, $1) }
- | TACTIC params { Ast.ETacticCtor ($loc, $1, $2) }
+ | PRED params { Ast.EPredCtor ($loc, $1, $2) }
| STRING { Ast.ESubsts ($loc, $1) }
| LEFT_ARRAY barelist RIGHT_ARRAY { Ast.EList ($loc, $2) }
;
| LEFT_PAREN separated_list(COMMA, expr) RIGHT_PAREN { $2 }
;
+(* This is used by Parse.parse_expr where we have to parse
+ * a standalone string (eg. from the command line).
+ *)
+expr_only:
+ | expr EOF { $1 }
+ ;
+
(* http://gallium.inria.fr/blog/lr-lists/ *)
right_flexible_list(delim, X):
| (* nothing *) { [] }