(* $Id: pxp_lex_document.src,v 1.6 2001/06/28 22:42:32 gerd Exp $
 * ----------------------------------------------------------------------
 *
 *)


{
  open Pxp_types
  open Pxp_lexer_types

#insert open_pxp_lex_aux_*.src
#insert open_pxp_lex_misc_*.src

}

#insert pxp_lex_defs_*.def


(* scan_document: Lexer for the outermost structures *)

rule scan_document = parse
    "<?" pi_string "?>"
      { scan_pi (Lexing.lexeme lexbuf) scan_xml_pi, Document }
  | "<?"
      { raise (WF_error ("Illegal processing instruction")) }
  | "<!DOCTYPE"
      { tok_Doctype__Document_type }
  | "<!--" 
      { Comment_begin dummy_entity, Document_comment }
  | "<!"
      { raise (WF_error "Declaration either malformed or not allowed in this context") 
      }
  | "<" name
      { let s = Lexing.lexeme lexbuf in
	Tag_beg (String.sub s 1 (String.length s - 1), dummy_entity), Within_tag
      }
  | '<'
      { raise (WF_error ("Illegal token")) }
  | ws+
      { tok_Ignore__Document }
  | eof
      { tok_Eof__Document }
  | character
      { raise (WF_error ("Content not allowed here")) }
  | _
      { raise Netconversion.Malformed_code }

(* ======================================================================
 * History:
 * 
 * $Log: pxp_lex_document.src,v $
 * Revision 1.6  2001/06/28 22:42:32  gerd
 * 	Comment tokens have entity_id
 *
 * Revision 1.5  2001/06/14 14:25:56  gerd
 * 	Removed insertion of pxp_lex_aux.src
 *
 * Revision 1.4  2000/08/18 20:19:59  gerd
 * 	Comments return different comment tokens.
 *
 * Revision 1.3  2000/08/14 22:18:34  gerd
 * 	Bad_character_stream -> Netconversion.Malformed_code
 *
 * Revision 1.2  2000/05/29 23:53:12  gerd
 * 	Updated because Markup_* modules have been renamed to Pxp_*.
 *
 * Revision 1.1  2000/05/20 20:33:25  gerd
 * 	Initial revision.
 *
 * 
 *)
