(***********************************************************************)
(*                                                                     *)
(*                                 GALAX                               *)
(*                              XQuery Engine                          *)
(*                                                                     *)
(*  Copyright 2001-2003, Lucent Technologies.                          *)
(*  Distributed only by permission.                                    *)
(*                                                                     *)
(***********************************************************************)

(* $Id: parseutil.mli,v 1.21 2003/06/27 00:05:08 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             : Glx_pxp.encoding;
      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;
      entity_value_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 set_lexer              :  Glx_pxp.rep_encoding -> 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 parse_statement_from_file   : string -> Xquery_ast.statement
val parse_statement_from_string : string -> Xquery_ast.statement

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
val mergeCFXQuery  : Xquery_ast.cquery_module -> Xquery_ast.cquery_module -> Xquery_ast.cquery_module

