X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2Fcomponents%2Fgrafite%2FgrafiteAstPp.ml;h=bd846248b848f0d2162038de0c5b627fa010bead;hb=08affd483123f36da15b38c89d58a0477bc96244;hp=43d03b9af5b42fc8e986978add05344f6336c9ee;hpb=560db5569f54fba5bded568699a33947f88df3ba;p=helm.git diff --git a/matita/components/grafite/grafiteAstPp.ml b/matita/components/grafite/grafiteAstPp.ml index 43d03b9af..bd846248b 100644 --- a/matita/components/grafite/grafiteAstPp.ml +++ b/matita/components/grafite/grafiteAstPp.ml @@ -26,6 +26,7 @@ (* $Id$ *) open GrafiteAst +open Printf let tactical_terminator = "" let tactic_terminator = tactical_terminator @@ -63,22 +64,23 @@ let rec pp_ntactic ~map_unicode_to_tex = (String.concat "," (List.map NotationPp.pp_term l)) ^ String.concat " " (List.map (fun a,b -> a ^ "=" ^ b) flgs) | NCases (_,what,where) -> "ncases " ^ NotationPp.pp_term what ^ - assert false ^ " " ^ assert false + "...to be implemented..." ^ " " ^ "...to be implemented..." | NConstructor (_,None,l) -> "@ " ^ String.concat " " (List.map NotationPp.pp_term l) | NConstructor (_,Some x,l) -> "@" ^ string_of_int x ^ " " ^ String.concat " " (List.map NotationPp.pp_term l) | NCase1 (_,n) -> "*" ^ n ^ ":" - | NChange (_,what,wwhat) -> "nchange " ^ assert false ^ + | NChange (_,what,wwhat) -> "nchange " ^ "...to be implemented..." ^ " with " ^ NotationPp.pp_term wwhat | NCut (_,t) -> "ncut " ^ NotationPp.pp_term t (*| NDiscriminate (_,t) -> "ndiscriminate " ^ NotationPp.pp_term t | NSubst (_,t) -> "nsubst " ^ NotationPp.pp_term t *) | NDestruct (_,dom,skip) -> "ndestruct ..." | NElim (_,what,where) -> "nelim " ^ NotationPp.pp_term what ^ - assert false ^ " " ^ assert false + "...to be implemented..." ^ " " ^ "...to be implemented..." | NId _ -> "nid" | NIntro (_,n) -> "#" ^ n + | NIntros (_,l) -> "#" ^ String.concat " " l | NInversion (_,what,where) -> "ninversion " ^ NotationPp.pp_term what ^ assert false ^ " " ^ assert false | NLApply (_,t) -> "lapply " ^ NotationPp.pp_term t @@ -86,19 +88,19 @@ let rec pp_ntactic ~map_unicode_to_tex = (match dir with `LeftToRight -> ">" | `RightToLeft -> "<") ^ " " ^ NotationPp.pp_term n ^ " " ^ pp_tactic_pattern where | NReduce _ | NGeneralize _ | NLetIn _ | NAssert _ -> "TO BE IMPLEMENTED" - | NDot _ -> "##." - | NSemicolon _ -> "##;" - | NBranch _ -> "##[" - | NShift _ -> "##|" - | NPos (_, l) -> "##" ^String.concat "," (List.map string_of_int l)^ ":" - | NPosbyname (_, s) -> "##" ^ s ^ ":" - | NWildcard _ -> "##*:" - | NMerge _ -> "##]" + | NDot _ -> "." + | NSemicolon _ -> ";" + | NBranch _ -> "[" + | NShift _ -> "|" + | NPos (_, l) -> String.concat "," (List.map string_of_int l)^ ":" + | NPosbyname (_, s) -> s ^ ":" + | NWildcard _ -> "*:" + | NMerge _ -> "]" | NFocus (_,l) -> - Printf.sprintf "##focus %s" + Printf.sprintf "focus %s" (String.concat " " (List.map string_of_int l)) - | NUnfocus _ -> "##unfocus" - | NSkip _ -> "##skip" + | NUnfocus _ -> "unfocus" + | NSkip _ -> "skip" | NTry (_,tac) -> "ntry " ^ pp_ntactic ~map_unicode_to_tex tac | NAssumption _ -> "nassumption" | NBlock (_,l) -> @@ -111,6 +113,53 @@ let pp_nmacro = function | Screenshot (_, name) -> Printf.sprintf "screenshot \"%s\"" name ;; +let pp_l1_pattern = NotationPp.pp_term +let pp_l2_pattern = NotationPp.pp_term + +let pp_alias = function + | Ident_alias (id, uri) -> sprintf "alias id \"%s\" = \"%s\"." id uri + | Symbol_alias (symb, instance, desc) -> + sprintf "alias symbol \"%s\" %s= \"%s\"." + symb + (if instance=0 then "" else "(instance "^ string_of_int instance ^ ") ") + desc + | Number_alias (instance,desc) -> + sprintf "alias num (instance %d) = \"%s\"." instance desc + +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_argument_pattern = function + | NotationPt.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 pp_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)) + (NotationPp.pp_cic_appl_pattern cic_appl_pattern) + +let pp_dir_opt = function + | None -> "" + | Some `LeftToRight -> "> " + | Some `RightToLeft -> "< " + +let pp_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) + let pp_ncommand = function | UnificationHint (_,t, n) -> "unification hint " ^ string_of_int n ^ " " ^ NotationPp.pp_term t @@ -126,19 +175,23 @@ let pp_ncommand = function (List.map (fun (a,b) -> NUri.string_of_uri a ^ " ↦ " ^ NUri.string_of_uri b) map) + | Include (_,mode,path) -> (* not precise, since path is absolute *) + if mode = WithPreferences then + "include \"" ^ path ^ "\"." + else + "include' \"" ^ path ^ "\"." + | Alias (_,s) -> pp_alias s + | Interpretation (_, dsc, (symbol, arg_patterns), cic_appl_pattern) -> + pp_interpretation dsc symbol arg_patterns cic_appl_pattern + | Notation (_, dir_opt, l1_pattern, assoc, prec, l2_pattern) -> + pp_notation dir_opt l1_pattern assoc prec l2_pattern ;; -let pp_command = function - | Include (_,path) -> "include \"" ^ path ^ "\"" - | Print (_,s) -> "print " ^ s - | Set (_, name, value) -> Printf.sprintf "set \"%s\" \"%s\"" name value - let pp_executable ~map_unicode_to_tex = function | NMacro (_, macro) -> pp_nmacro macro ^ "." | NTactic (_,tacl) -> String.concat " " (List.map (pp_ntactic ~map_unicode_to_tex) tacl) - | Command (_, cmd) -> pp_command cmd ^ "." | NCommand (_, cmd) -> pp_ncommand cmd ^ "." let pp_comment ~map_unicode_to_tex =