X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_notation%2FgrafiteAstPp.ml;h=3e19ed28140c6b2b5ed1fcdf98e6cc4a58f84001;hb=97c2d258a5c524eb5c4b85208899d80751a2c82f;hp=6af1efd714406afea6c87e2bf0d37af966b402ae;hpb=cb473667ca89549ed0ca6dd2bfb03a5fe9eeaa82;p=helm.git diff --git a/helm/ocaml/cic_notation/grafiteAstPp.ml b/helm/ocaml/cic_notation/grafiteAstPp.ml index 6af1efd71..3e19ed281 100644 --- a/helm/ocaml/cic_notation/grafiteAstPp.ml +++ b/helm/ocaml/cic_notation/grafiteAstPp.ml @@ -27,7 +27,9 @@ open Printf open GrafiteAst -let tactical_terminator = "." +module Ast = CicNotationPt + +let tactical_terminator = "" let tactic_terminator = tactical_terminator let command_terminator = tactical_terminator @@ -39,10 +41,12 @@ let pp_idents idents = "[" ^ String.concat "; " idents ^ "]" let pp_terms_ast terms = String.concat ", " (List.map pp_term_ast terms) let pp_reduction_kind = function + | `Normalize -> "normalize" | `Reduce -> "reduce" | `Simpl -> "simplify" + | `Unfold (Some t) -> "unfold " ^ pp_term_ast t + | `Unfold None -> "unfold" | `Whd -> "whd" - | `Normalize -> "normalize" let pp_pattern (t, hyp, goal) = @@ -237,7 +241,7 @@ let pp_obj = function pp_fields fields ^ "}" let pp_argument_pattern = function - | CicNotationPt.IdentArg (eta_depth, name) -> + | Ast.IdentArg (eta_depth, name) -> let eta_buf = Buffer.create 5 in for i = 1 to eta_depth do Buffer.add_string eta_buf "\\eta." @@ -245,10 +249,10 @@ let pp_argument_pattern = function sprintf "%s%s" (Buffer.contents eta_buf) name let rec pp_cic_appl_pattern = function - | CicNotationPt.UriPattern uri -> UriManager.string_of_uri uri - | CicNotationPt.VarPattern name -> name - | CicNotationPt.ImplicitPattern -> "_" - | CicNotationPt.ApplPattern aps -> + | Ast.UriPattern uri -> UriManager.string_of_uri uri + | Ast.VarPattern name -> name + | Ast.ImplicitPattern -> "_" + | Ast.ApplPattern aps -> sprintf "(%s)" (String.concat " " (List.map pp_cic_appl_pattern aps)) let pp_l1_pattern = CicNotationPp.pp_term @@ -261,6 +265,16 @@ let pp_associativity = function let pp_precedence i = sprintf "with precedence %d" i +let pp_dir_opt = function + | None -> "" + | Some `LeftToRight -> "> " + | Some `RightToLeft -> "< " + +let pp_metadata = + function + | Dependency buri -> sprintf "dependency %s" buri + | Baseuri buri -> sprintf "baseuri %s" buri + let pp_command = function | Include (_,path) -> "include " ^ path | Qed _ -> "qed" @@ -277,12 +291,14 @@ let pp_command = function dsc symbol (String.concat " " (List.map pp_argument_pattern arg_patterns)) (pp_cic_appl_pattern cic_appl_pattern) - | Notation (_, l1_pattern, assoc, prec, l2_pattern) -> - sprintf "notation \"%s\" %s %s for %s" + | Notation (_, dir_opt, l1_pattern, assoc, prec, l2_pattern) -> + sprintf "notation %s\"%s\" %s %s for %s" + (pp_dir_opt dir_opt) (pp_l1_pattern l1_pattern) (pp_associativity assoc) (pp_precedence prec) (pp_l2_pattern l2_pattern) + | Metadata (_, m) -> sprintf "metadata %s" (pp_metadata m) | Render _ | Dump _ -> assert false (* ZACK: debugging *) @@ -297,16 +313,27 @@ let rec pp_tactical = function | Try (_, tac) -> "try " ^ pp_tactical tac | Solve (_, tac) -> sprintf "solve [%s]" (pp_tacticals ~sep:" | " tac) -and pp_tacticals ~sep tacs = - String.concat sep (List.map pp_tactical tacs) + | Dot _ -> "." + | Semicolon _ -> ";" + | Branch _ -> "[" + | Shift _ -> "|" + | Pos (_, i) -> sprintf "%d:" i + | Merge _ -> "]" + | Focus (_, goals) -> + sprintf "focus %s" (String.concat " " (List.map string_of_int goals)) + | Unfocus _ -> "unfocus" + | Skip _ -> "skip" + +and pp_tacticals ~sep tacs = String.concat sep (List.map pp_tactical tacs) -let pp_tactical tac = pp_tactical tac ^ tactical_terminator -let pp_tactic tac = pp_tactic tac ^ tactic_terminator -let pp_command tac = pp_command tac ^ command_terminator +let pp_tactical tac = pp_tactical tac +let pp_tactic tac = pp_tactic tac +let pp_command tac = pp_command tac let pp_executable = function | Macro (_,x) -> pp_macro_ast x - | Tactical (_,x) -> pp_tactical x + | Tactical (_, tac, Some punct) -> pp_tactical tac ^ pp_tactical punct + | Tactical (_, tac, None) -> pp_tactical tac | Command (_,x) -> pp_command x let pp_comment = function @@ -328,6 +355,12 @@ let pp_cic_command = function | Render _ | Dump _ | Interpretation _ + | Metadata _ | Notation _ | Obj _ -> assert false (* not implemented *) +let pp_dependency = function + | IncludeDep str -> "include \"" ^ str ^ "\"" + | BaseuriDep str -> "set \"baseuri\" \"" ^ str ^ "\"" + | UriDep uri -> "uri \"" ^ UriManager.string_of_uri uri ^ "\"" +