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

(* $Id: parseutil.mli,v 1.16 2002/11/21 18:39:42 simeon Exp $ *)

(******************************)
(* post-parsing verifications *)
(******************************)

val check_multi_def : Xquery_ast.cquery_module -> unit
    (* checks whether variables or functions are multiply defined *)

(*******************)
(* Lexers handling *)
(*******************)

type xml_lexers =
    { encoding             : Conf.encoding_kind;
      opening_tag_state    : Lexing.lexbuf -> Xquery_parser.token;
      closing_tag_state    : Lexing.lexbuf -> Xquery_parser.token;
      text_state           : Lexing.lexbuf -> Xquery_parser.token;
      attribute_text_state : Lexing.lexbuf -> Xquery_parser.token;
      pi_state             : Lexing.lexbuf -> Xquery_parser.token;
      cdata_state          : Lexing.lexbuf -> Xquery_parser.token;
      comment_state        : Lexing.lexbuf -> Xquery_parser.token;
      xml_decl_state       : Lexing.lexbuf -> Xquery_parser.token;
      xml_document_state   : Lexing.lexbuf -> Xquery_parser.token;
      doctype_state        : Lexing.lexbuf -> Xquery_parser.token;
      dtddecl_state        : Lexing.lexbuf -> Xquery_parser.token }


type language_lexers =
    { language             : Lexutil.language_kind;
      schema_state         : Lexing.lexbuf -> Xquery_parser.token;
      default_state        : Lexing.lexbuf -> Xquery_parser.token }

val register_lexer         :  xml_lexers -> unit

(*
val use_default_lexer      :  unit -> unit
val use_lexer_for_encoding :  unit -> unit
*)

(*******************)
(* Lexing wrappers *)
(*******************)

(* XQuery lexer *)

val xquery_lexfun : Lexing.lexbuf -> Xquery_parser.token
val xml_lexfun : Lexing.lexbuf -> Xquery_parser.token

(********************)
(* Parsing wrappers *)
(********************)

(* parse Full XQuery expressions *)

val parseFXQuery : string -> Xquery_ast.query_module
val parseStringFXQuery : string -> Xquery_ast.query_module

val parseFXQueryExpr : string -> Xquery_ast.expr
val parseStringFXQueryExpr : string -> Xquery_ast.expr

val lexerFXQuery : string -> Tokens.tokens
val lexerStringFXQuery : string -> Tokens.tokens

(* parser XML fragments *)

val parseXML : string -> Xml_ast.xml_document
val parseXMLString : string -> Xml_ast.xml_document

(* parser XML schemas *)

val parseXMLSchema : string -> Xml_ast.xml_document
val parseXMLSchemaString : string -> Xml_ast.xml_document

(*****************************)
(* Module related operations *)
(*****************************)

val mergeFXQuery  : Xquery_ast.query_module -> Xquery_ast.query_module -> Xquery_ast.query_module

