(***********************************************************************)
(*                                                                     *)
(*                                 GALAX                               *)
(*                           XML Query Engine                          *)
(*                                                                     *)
(*  Copyright 2000, Lucent Technologies.                               *)
(*  Distributed only by permission.                                    *)
(*                                                                     *)
(***********************************************************************)

(* $Id: sym.mli,v 1.3 2002/12/03 00:01:42 simeon Exp $ *)

(************************************************)
(* This module implements qname symbols support *)
(************************************************)

open Namespace

(*********************************)
(* Operations on element symbols *)
(*********************************)

(* Operations on unresolved element symbols *)

type uelem_symbol

val uelem_symbol : uqname -> uelem_symbol
val uelem_name   : uelem_symbol -> uqname

val uelem_exists : uqname -> bool
val uelem_string : uelem_symbol -> string

(* Operations on resolved element symbols *)

type relem_symbol

(* val relem_symbol : rqname -> relem_symbol *)

val relem_name   : relem_symbol -> rqname

val relem_symbol : (prefix * rqname) -> relem_symbol
val relem_prefix : relem_symbol -> prefix

val relem_exists : rqname -> bool
val relem_equals : relem_symbol -> relem_symbol -> bool
val relem_subtag : relem_symbol -> relem_symbol -> bool

val relem_string        : relem_symbol -> string         (* prints the resolved QName *)
val relem_prefix_string : relem_symbol -> string         (* prints the original prefixed QName *)

(* Special symbols *)

val anyrelem : relem_symbol

(************************************)
(* Operations on attributes symbols *)
(************************************)

(* Operations on unresolved attribute symbols *)

type uattr_symbol

val uattr_symbol : uqname -> uattr_symbol
val uattr_name   : uattr_symbol -> uqname

val uattr_exists : uqname -> bool
val uattr_string : uattr_symbol -> string

(* Operations on resolved attribute symbols *)

type rattr_symbol

val rattr_name   : rattr_symbol -> rqname
val rattr_symbol : (prefix * rqname) -> rattr_symbol
val rattr_prefix : rattr_symbol -> prefix

val rattr_exists : rqname -> bool
val rattr_equals : rattr_symbol -> rattr_symbol -> bool
val rattr_subtag : rattr_symbol -> rattr_symbol -> bool

val rattr_string        : rattr_symbol -> string         (* prints the resolved QName *)
val rattr_prefix_string : rattr_symbol -> string         (* prints the original prefixed QName *)

(* Special symbols *)

val anyrattr : rattr_symbol

(*******************************)
(* Operations on group symbols *)
(*******************************)

(* Operations on unresolved group symbols *)

type ugroup_symbol

val ugroup_symbol : uqname -> ugroup_symbol
val ugroup_name   : ugroup_symbol -> uqname

val ugroup_exists : uqname -> bool
val ugroup_string : ugroup_symbol -> string

(* Operations on resolved group symbols *)

type rgroup_symbol

val rgroup_name   : rgroup_symbol -> rqname

val rgroup_symbol : (prefix * rqname) -> rgroup_symbol
val rgroup_prefix : rgroup_symbol -> prefix
val rgroup_exists : rqname -> bool
val rgroup_equals : rgroup_symbol -> rgroup_symbol -> bool

val rgroup_string        : rgroup_symbol -> string         (* prints the resolved QName *)
val rgroup_prefix_string : rgroup_symbol -> string         (* prints the original prefixed QName *)

(* Special symbols *)

val anynumeric           : rgroup_symbol
val anyscalar            : rgroup_symbol
val anysimpletype        : rgroup_symbol
val anyattribute         : rgroup_symbol
val anyelement           : rgroup_symbol
val anydoc               : rgroup_symbol
val anytype              : rgroup_symbol
val anynode              : rgroup_symbol
val anyitem              : rgroup_symbol

val roottypesym          : rgroup_symbol

(*************************************)
(* Operations on simple type symbols *)
(*************************************)

type simple_symbol

val simple_name    : simple_symbol -> rqname
val simple_symbol : (prefix * rqname) -> simple_symbol
val simple_prefix : simple_symbol -> prefix

val simple_exists  : rqname -> bool
val simple_equals  : simple_symbol -> simple_symbol -> bool

val simple_string        : simple_symbol -> string         (* prints the resolved QName *)
val simple_prefix_string : simple_symbol -> string         (* prints the original prefixed QName *)

(* Special symbols *)

val anyscalarsym         : simple_symbol

val stringsym            : simple_symbol
val booleansym           : simple_symbol
val decimalsym           : simple_symbol
val floatsym             : simple_symbol
val doublesym            : simple_symbol
val durationsym          : simple_symbol
val dateTimesym          : simple_symbol
val timesym              : simple_symbol
val datesym              : simple_symbol
val gYearMonthsym        : simple_symbol
val gYearsym             : simple_symbol
val gMonthDaysym         : simple_symbol
val gDaysym              : simple_symbol
val gMonthsym            : simple_symbol
val hexBinarysym         : simple_symbol
val base64Binarysym      : simple_symbol
val anyURIsym            : simple_symbol
val qnamesym             : simple_symbol
val notationsym          : simple_symbol

val integersym           : simple_symbol
val intsym               : simple_symbol

val untypedsym           : simple_symbol

val nssym                : simple_symbol
val pisym                : simple_symbol
val commentsym           : simple_symbol
val cdatasym             : simple_symbol
val refsym               : simple_symbol

(***********************************)
(* Operations on namespace symbols *)
(***********************************)

type ns_symbol

val ns_symbol : rqname -> ns_symbol
val ns_name   : ns_symbol -> rqname

val ns_exists : rqname -> bool
val ns_equals : ns_symbol -> ns_symbol -> bool
val ns_string : ns_symbol -> string

(***********************************)
(* Operations on anonymous symbols *)
(***********************************)

type anon_symbol

val anon_symbol : rqname -> anon_symbol
val anon_name   : anon_symbol -> rqname
val anon_prefix : anon_symbol -> prefix

val anon_exists : rqname -> bool
val anon_equals : anon_symbol -> anon_symbol -> bool

val anon_string        : anon_symbol -> string
val anon_prefix_string : anon_symbol -> string

(************************)
(* Generic symbol types *)
(************************)

(* Generic element symbols *)

type elem_symbol =
  | UElemSym of uelem_symbol
  | RElemSym of relem_symbol

val relem_symbol_of_elem_symbol : elem_symbol -> relem_symbol
val string_of_elem_symbol : elem_symbol -> string
val string_prefix_of_elem_symbol : elem_symbol -> string

(* Generic attribute symbols *)

type attr_symbol =
  | UAttrSym of uattr_symbol
  | RAttrSym of rattr_symbol

val rattr_symbol_of_attr_symbol : attr_symbol -> rattr_symbol
val string_of_attr_symbol : attr_symbol -> string
val string_prefix_of_attr_symbol : attr_symbol -> string

(* Generic group symbols *)

type group_symbol =
  | UGroupSym of ugroup_symbol
  | RGroupSym of rgroup_symbol

val rgroup_symbol_of_group_symbol : group_symbol -> rgroup_symbol
val string_of_group_symbol : group_symbol -> string
val string_prefix_of_group_symbol : group_symbol -> string

(* Generic resolved symbols *)

type resolved_unit_symbol =
  | RUnitTupleSymbol                      (* for tuples *)
  | RUnitDocSymbol                        (* for documents *)
  | RUnitElemSymbol   of relem_symbol     (* for elements *)
  | RUnitAttrSymbol   of rattr_symbol     (* for attributes *)
  | RUnitTextSymbol                       (* for text nodes *)
  | RUnitSimpleSymbol of simple_symbol    (* for simple types *)
  | RUnitNSSymbol     of ns_symbol        (* for namespaces *)
  | RUnitAnonSymbol   of anon_symbol      (* for anonymous symbols *)

val subtag   : resolved_unit_symbol -> resolved_unit_symbol -> bool
val equaltag : resolved_unit_symbol -> resolved_unit_symbol -> bool

val label_string : resolved_unit_symbol -> string

val relem_symbol_of_unit_symbol   : resolved_unit_symbol -> relem_symbol
val rattr_symbol_of_unit_symbol   : resolved_unit_symbol -> rattr_symbol
val rsimple_symbol_of_unit_symbol : resolved_unit_symbol -> simple_symbol
val rns_symbol_of_unit_symbol     : resolved_unit_symbol -> ns_symbol
val ranon_symbol_of_unit_symbol   : resolved_unit_symbol -> anon_symbol


(**************)
(* Statistics *)
(**************)

type sym_stats =
    { unresolved_element_names : (int * int * int);
      unresolved_attribute_names : (int * int * int);
      unresolved_type_names : (int * int * int);
      resolved_anon_names : (int * int * int);
      resolved_element_names : (int * int * int);
      resolved_attribute_names : (int * int * int);
      resolved_type_names : (int * int * int) }

val stats : unit -> sym_stats

