X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=src%2Fast.mli;h=e47ddc35fd1b65c5770e74fef64eb38b5c83a6bb;hb=3ed50d510dbab127125a8af9f72554c2dec72ef5;hp=c59de0042240f6d1f1b4aa3fbcfad3f3d495e887;hpb=28a34f592996bec9dc524f1741764878c9c85e1c;p=goals.git diff --git a/src/ast.mli b/src/ast.mli index c59de00..e47ddc3 100644 --- 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 + + (* 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 *) @@ -40,16 +43,15 @@ type env = expr Env.t and pattern = (** match tactic such as *file ("filename") *) | PTactic of loc * id * substs list - (** match named variable, which must be a string, ETactic or - a list of those *) - | PVar of loc * id and expr = - (** goal (params) = patterns : exprs = code *) - | EGoal of loc * goal - (** goalname (params) etc. *) - | ECall of loc * id * expr list - (** *tactic (params) etc. *) - | ETactic of loc * id * expr list + (** goal (params) = patterns : exprs code *) + | EGoalDefn of loc * goal + (** tactic (params) = code *) + | ETacticDefn of loc * tactic + (** call goalname (params) etc. *) + | ECallGoal of loc * id * expr list + (** call *tactic (params) etc. *) + | ETacticCtor of loc * id * expr list (** variable, or goal call with no parameters *) | EVar of loc * id (** list *) @@ -60,7 +62,10 @@ and expr = | EConstant of loc * constant and constant = | CString of string -and goal = id list * pattern list * expr list * code option +and goal = param_decl list * pattern list * expr list * code option +and tactic = param_decl list * code + (** Goal/tactic parameter. *) +and param_decl = id and id = string and code = substs and substs = subst list @@ -78,6 +83,10 @@ val getvar : env -> loc -> id -> expr found or if the named variable is not a goal. *) val getgoal : env -> loc -> id -> goal +(** Look up a tactic in the environment. Raise [Failure _] if not + found or if the named variable is not a tactic. *) +val gettactic : env -> loc -> id -> tactic + (** Take any expression and simplify it down to a constant. If the expression cannot be simplified then this raises [Failure _]. *) @@ -88,6 +97,12 @@ val to_constant : env -> expr -> constant raises [Failure _]. *) val substitute : env -> loc -> substs -> string +(** 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 + (** This is used for incrementally building Ast.substs in the parser. *) module Substs : sig type t @@ -98,9 +113,8 @@ module Substs : sig val add_var : t -> string -> unit end -(** Print all definitions in an environment. *) -val print_env : out_channel -> env -> unit - (** %a formatters. *) +val print_env : out_channel -> env -> unit val string_pattern : unit -> pattern -> string val string_expr : unit -> expr -> string +val print_expr : out_channel -> expr -> unit