X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_notation%2FgrafiteAstPp.ml;h=3e19ed28140c6b2b5ed1fcdf98e6cc4a58f84001;hb=4167cea65ca58897d1a3dbb81ff95de5074700cc;hp=db7a7253e30888f1a913d66a738ccc9b52806b39;hpb=e20f3963028a966fc93ba0d611c4aa8341d20e2c;p=helm.git diff --git a/helm/ocaml/cic_notation/grafiteAstPp.ml b/helm/ocaml/cic_notation/grafiteAstPp.ml index db7a7253e..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) = @@ -78,8 +82,15 @@ let rec pp_tactic = function "cut " ^ pp_term_ast term ^ (match ident with None -> "" | Some id -> " as " ^ id) | DecideEquality _ -> "decide equality" - | Decompose (_, term) -> - sprintf "decompose %s" (pp_term_ast term) + | Decompose (_, [], what, names) -> + sprintf "decompose %s%s" what (pp_intros_specs (None, names)) + | Decompose (_, types, what, names) -> + let to_ident = function + | Ident id -> id + | Type _ -> assert false + in + let types = List.rev_map to_ident types in + sprintf "decompose %s %s%s" (pp_idents types) what (pp_intros_specs (None, names)) | Discriminate (_, term) -> "discriminate " ^ pp_term_ast term | Elim (_, term, using, num, idents) -> sprintf "elim " ^ pp_term_ast term ^ @@ -229,6 +240,41 @@ let pp_obj = function "record " ^ name ^ " " ^ pp_params params ^ " \\def {" ^ pp_fields fields ^ "}" +let pp_argument_pattern = function + | 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." + done; + sprintf "%s%s" (Buffer.contents eta_buf) name + +let rec pp_cic_appl_pattern = function + | 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 +let pp_l2_pattern = CicNotationPp.pp_term + +let pp_associativity = function + | Gramext.LeftA -> "left associative" + | Gramext.RightA -> "right associative" + | Gramext.NonA -> "non associative" + +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" @@ -240,6 +286,21 @@ let pp_command = function | Default (_,what,uris) -> sprintf "default \"%s\" %s" what (String.concat " " (List.map UriManager.string_of_uri uris)) + | Interpretation (_, dsc, (symbol, arg_patterns), cic_appl_pattern) -> + sprintf "interpretation \"%s\" '%s %s = %s" + dsc symbol + (String.concat " " (List.map pp_argument_pattern arg_patterns)) + (pp_cic_appl_pattern cic_appl_pattern) + | 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 *) let rec pp_tactical = function | Tactic (_, tac) -> pp_tactic tac @@ -252,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" -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 +and pp_tacticals ~sep tacs = String.concat sep (List.map pp_tactical tacs) + +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 @@ -277,7 +349,18 @@ let pp_cic_command = function | Qed _ -> "qed" | Drop _ -> "drop" | Coercion (_,term) -> sprintf "coercion %s" (CicPp.ppterm term) - | Set (_, _, _) - | Alias (_,_) - | Default (_,_,_) - | Obj (_,_) -> assert false (* not implemented *) + | Set _ + | Alias _ + | Default _ + | 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 ^ "\"" +