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

(* $Id: lexutil.mli,v 1.5 2002/09/03 19:52:09 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
  | AttributeTextState
  | PIState
  | CDATAState
  | CommentState
  | XMLDeclState
  | XMLDocumentState
  | DocTypeState


(********************)
(* 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

(* Text content *)

val reset_text         : unit -> unit
val add_text           : char -> unit
val get_text           : unit -> string option

(**************************)
(* 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

(* 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         : 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 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

