(* $Id$ *)
open GrafiteAst
+open Printf
let tactical_terminator = ""
let tactic_terminator = tactical_terminator
(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
(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) ->
| 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
(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