(******************************************************************************) (* SXSI : XPath evaluator *) (* Kim Nguyen (Kim.Nguyen@nicta.com.au) *) (* Copyright NICTA 2008 *) (* Distributed under the terms of the LGPL (see LICENCE) *) (******************************************************************************) (* maybe utf8 string... *) type t = int external to_int : t -> int = "%identity" type operations = { tag : string -> t; to_string : t -> string; translate : t -> t } type intern = { mutable tag_ : string -> t; mutable to_string_ : t ->string; mutable translate_ : t -> t } let dummy_fun =function _ -> failwith "Tag.ml Uninitialized tag structure" let ops = { tag_ = dummy_fun; to_string_ = dummy_fun; translate_ = dummy_fun } let init p = ops.tag_ <- p.tag; ops.to_string_ <- p.to_string; ops.translate_ <- p.translate let tag s = ops.tag_ s let to_string t = ops.to_string_ t let translate s = ops.translate_ s let nullt = ~-1 let dummy = nullt (* Defined in XMLTree.cpp *) let document_node = 0 let attribute = 1 let pcdata = 2 let attribute_data= 3 let document_node_close = 4 let attribute_close = 5 let pcdata_close = 6 let attribute_data_close= 7 let compare = (-) let equal = (==) let hash x = x (* let dump_tags () = Format.eprintf "Tags are:\n"; let doc = get_pool() in let ntags = num_tags doc in for i = 0 to ntags - 1 do Format.eprintf "%i, -><%s/>\n%!" i (to_string i) done *) let print ppf t = Format.fprintf ppf "%s" (to_string t) (* Check internal invariants *) let check t = if (t != tag (to_string t)) then failwith "module Tag: internal check failed" let dump = print (* To move *)