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

(* $Id: lexutil.mli,v 1.8 2003/01/10 18:41:53 simeon Exp $ *)

(* This module contains helper functions used by the lexer *)

(****************************)
(* Lexing global parameters *)
(****************************)

(* Language currently parsed *)

type language_kind =
  | XML_1_0
  | XPath_2_0
  | XQuery_1_0


(* Lexical state *)

type lex_state =
  | SchemaState
  | DefaultState
  | OpeningTagState
  | ClosingTagState
  | TextState
  | AttributeTextDoubleState
  | AttributeTextSingleState
  | PIState
  | CDATAState
  | CommentState
  | XMLDeclState
  | XMLDocumentState
  | DocTypeState
  | DTDDeclState


(********************)
(* Comment handling *)
(********************)

val depth : int ref

(****************************)
(* String and text handling *)
(****************************)

(* String content *)

val reset_string : unit -> unit
val add_string   : char -> unit
val get_string   : unit -> string

(**************************)
(* Lexical state handling *)
(**************************)

(* Initialization of the lexical state *)

val init_xquery_lexing : unit -> unit
val init_xml_lexing    : unit -> unit

(* Accesses the current lexical state *)

val get_current_lex_state : unit -> lex_state

(* Accesses the current quote kind *)

val single_quote_kind : unit -> bool

(* Stack discipline for the lexical state *)

val push_schema                 : unit -> unit

val push_default                : unit -> unit
val push_text                   : unit -> unit
val push_attribute_text_single  : unit -> unit
val push_attribute_text_double  : unit -> unit
val push_opening_tag            : unit -> unit
val push_closing_tag            : unit -> unit
val push_processing_instruction : unit -> unit
val push_cdata                  : unit -> unit
val push_comment                : unit -> unit
val push_xmldecl                : unit -> unit
val push_xmldocument            : unit -> unit
val push_doctype                : unit -> unit
val push_dtddecl                : unit -> unit

val pop_state                   : unit -> unit

(* Parse kind *)

val get_parsing_kind : unit -> language_kind


(********************)
(* Token processing *)
(********************)

(* Extracts an axis name *)

val get_axis : string -> Xquery_ast.axis

(* Extracts the type name in a type definition *)

val get_type_defn : string -> Namespace.uqname

(* Extracts the element name in an element declaration *)

val get_element_defn : string -> Namespace.uqname

(* Extracts escaped name *)

val get_escaped_name : string -> string

(* Extracts the attribute name in an attribute declaration *)

val get_attribute_defn : string -> Namespace.uqname

(* Extracts the function name in a function definition *)

val get_function_name : string -> Namespace.uqname

(* Extracts the PI target *)

val get_target_pi : string -> string

(* Extracts the character encoding *)

val get_xml_encoding_quotes : string -> Conf.encoding_kind
val get_xml_encoding_single_quotes : string -> Conf.encoding_kind

(* Extracts character and entity references *)

val get_char_ref       : string -> string
val get_hexchar_ref    : string -> string
val get_entity_ref     : string -> string

