module Ast = NotationPt
-let visit_ast ?(special_k = fun _ -> assert false)
+let visit_ast ?(special_k = fun _ -> assert false)
+ ?(clear_interpretation= false)
?(map_xref_option= fun x -> x) ?(map_case_indty= fun x -> x)
?(map_case_outtype=
fun k x -> match x with None -> None | Some x -> Some (k x))
| Ast.Literal _
| Ast.Magic _
| Ast.Variable _) as t -> special_k t
- | (Ast.Ident _
+ | Ast.Ident (id,_) when clear_interpretation -> Ast.Ident (id,`Ambiguous)
+ | Ast.Symbol (s,_) when clear_interpretation -> Ast.Symbol (s,None)
+ | Ast.Num (n,_) when clear_interpretation -> Ast.Num (n,None)
+ | ( Ast.Ident _
+ | Ast.Symbol _
+ | Ast.Num _
| Ast.NRef _
| Ast.NCic _
| Ast.Implicit _
- | Ast.Num _
| Ast.Sort _
- | Ast.Symbol _
| Ast.UserInput) as t -> t
and aux_opt = function
| None -> None
let rec aux = function
| Ast.AttributedTerm (_, t) -> aux t
| Ast.Layout l -> Ast.Layout (visit_layout aux l)
- | Ast.Literal (`Keyword k) as t ->
+ | Ast.Literal (_,`Keyword (k,_)) as t ->
add_keyword k;
t
| Ast.Literal _ as t -> t
let rec get_idrefs =
function
- | Ast.AttributedTerm (`IdRef id, t) -> id :: get_idrefs t
- | Ast.AttributedTerm (_, t) -> get_idrefs t
+ | Ast.Symbol (csym,Some (uri,desc)) -> [csym,uri,desc]
| _ -> []
let meta_names_of_term term =
done;
List.rev !lists
+let href s = function
+ | None, None -> s
+ | Some u, None -> "<A href=\"" ^ u ^ "\">" ^ s ^ "</A>"
+ | None, Some desc ->
+ "<A href=\"cic:/fakeuri.con\" title=\"" ^ desc ^ "\">" ^ s ^ "</A>"
+ | Some u, Some desc ->
+ "<A href=\"" ^ u ^ "\" title=\"" ^ desc ^ "\">" ^ s ^ "</A>"
+
let string_of_literal = function
- | `Symbol s
- | `Keyword s
- | `Number s -> s
+ | `Symbol (s,x)
+ | `Keyword (s,x)
+ | `Number (s,x) -> href s x
+
+let html_of_literal = function
+ | `Symbol (s,x)
+ | `Keyword (s,x)
+ | `Number (s,x) ->
+ href (Netencoding.Html.encode ~in_enc:`Enc_utf8 ()
+ (Utf8Macro.unicode_of_tex s)) x
let boxify = function
| [ a ] -> a