git.annexia.org
/
goals.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lexer: Use @{...} for quiet code sections.
[goals.git]
/
src
/
ast.mli
diff --git
a/src/ast.mli
b/src/ast.mli
index
9bb2c9a
..
371c209
100644
(file)
--- a/
src/ast.mli
+++ b/
src/ast.mli
@@
-26,6
+26,9
@@
module Env : sig
val fold: (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val filter: (key -> 'a -> bool) -> 'a t -> 'a t
val bindings: 'a t -> (key * 'a) list
val fold: (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val filter: (key -> 'a -> bool) -> 'a t -> 'a t
val bindings: 'a t -> (key * 'a) list
+
+ (* This is not the normal Map.merge function. *)
+ val merge : 'a t -> 'a t -> 'a t
end
(** Location where we parsed from $loc = $startpos, $endpos *)
end
(** Location where we parsed from $loc = $startpos, $endpos *)
@@
-38,63
+41,58
@@
val string_loc : unit -> loc -> string
variable or goal name -> expression. *)
type env = expr Env.t
and pattern =
variable or goal name -> expression. *)
type env = expr Env.t
and pattern =
- (** match tactic such as *file ("filename") *)
| PTactic of loc * id * substs list
| PTactic of loc * id * substs list
- (** match named variable, which must be a string, ETactic or
- a list of those *)
- | PVar of loc * id
+ (** match tactic such as *file ("filename") *)
and expr =
and expr =
- (** goal (params) = patterns : exprs = code *)
- | EGoal of loc * goal
- (** goalname (params) etc. *)
+ | EGoalDefn of loc * goal
+ (** goal (params) = patterns : exprs code *)
+ | EFuncDefn of loc * func
+ (** function (params) = code *)
+ | ETacticDefn of loc * tactic
+ (** tactic (params) = code *)
| ECall of loc * id * expr list
| ECall of loc * id * expr list
- (**
*tactic (params) etc.
*)
- | ETactic of loc * id * expr list
- (**
variable, or goal call with no parameters
*)
+ (**
call goal (params) or function (params)
*)
+ | ETactic
Ctor
of loc * id * expr list
+ (**
constructor *tactic (params)
*)
| EVar of loc * id
| EVar of loc * id
- (**
list
*)
+ (**
variable, or goal call with no parameters
*)
| EList of loc * expr list
| EList of loc * expr list
- (**
string with %-substitutions
*)
+ (**
list
*)
| ESubsts of loc * substs
| ESubsts of loc * substs
- (**
constant expression, such as a plain string, int, boolean, etc.
*)
+ (**
string with %-substitutions
*)
| EConstant of loc * constant
| EConstant of loc * constant
+ (** constant expression, such as a plain string, int, boolean, etc. *)
and constant =
| CString of string
and goal = param_decl list * pattern list * expr list * code option
and constant =
| CString of string
and goal = param_decl list * pattern list * expr list * code option
- (** Goal parameter is the parameter name and an optional default value. *)
-and param_decl = id
+and func = param_decl list * returning * code
+and tactic = param_decl list * code
+and param_decl = id (** goal/func/tactic parameter. *)
and id = string
and id = string
-and code = substs
+and code = substs * bool (** code + quiet flag *)
+and returning = RetExpr | RetStrings | RetString
and substs = subst list
and subst =
and substs = subst list
and subst =
- (** String literal part. *)
| SString of string
| SString of string
- (**
%-substitution
. *)
+ (**
String literal part
. *)
| SVar of id
| SVar of id
+ (** %-substitution. *)
+val getvar : env -> loc -> id -> expr
(** Look up a variable in the environment. Raise [Failure _]
if not found. *)
(** Look up a variable in the environment. Raise [Failure _]
if not found. *)
-val getvar : env -> loc -> id -> expr
+val getgoal : env -> loc -> id -> goal
(** Look up a goal in the environment. Raise [Failure _] if not
found or if the named variable is not a goal. *)
(** Look up a goal in the environment. Raise [Failure _] if not
found or if the named variable is not a goal. *)
-val getgoal : env -> loc -> id -> goal
-
-(** Take any expression and simplify it down to a constant.
- If the expression cannot be simplified then this raises
- [Failure _]. *)
-val to_constant : env -> expr -> constant
-(** Take a substitution list and try to turn it into a simple
- string by evaluating every variable. If not possible this
- raises [Failure _]. *)
-val substitute : env -> loc -> substs -> string
+val getfunc : env -> loc -> id -> func
+(** Look up a function in the environment. Raise [Failure _] if not
+ found or if the named variable is not a function. *)
-(** Similar to {!substitute} except this is used where we will
- pass the result immediately to the shell to execute. Variables
- are substituted with shell quoted strings. Raises [Failure _]
- on error. *)
-val to_shell_script : env -> loc -> substs -> string
+val gettactic : env -> loc -> id -> tactic
+(** Look up a tactic in the environment. Raise [Failure _] if not
+ found or if the named variable is not a tactic. *)
(** This is used for incrementally building Ast.substs in the parser. *)
module Substs : sig
(** This is used for incrementally building Ast.substs in the parser. *)
module Substs : sig
@@
-106,9
+104,8
@@
module Substs : sig
val add_var : t -> string -> unit
end
val add_var : t -> string -> unit
end
-(** Print all definitions in an environment. *)
-val print_env : out_channel -> env -> unit
-
(** %a formatters. *)
(** %a formatters. *)
+val print_env : out_channel -> env -> unit
val string_pattern : unit -> pattern -> string
val string_expr : unit -> expr -> string
val string_pattern : unit -> pattern -> string
val string_expr : unit -> expr -> string
+val print_expr : out_channel -> expr -> unit