Commit bd42e948 authored by François Bobot's avatar François Bobot

xml parser : use @. instead of @\n otherwise the message

appears only if it is big enough (that give a strange behaviour ;) )

use debug flag
parent 3843cb84
......@@ -52,6 +52,8 @@
exception Parse_error of string
let parse_error s = raise (Parse_error s)
open Debug
let debug = register_flag "xml"
}
......@@ -73,7 +75,7 @@ rule xml_prolog = parse
| "<?xml" space+ "version=\"1.0\"" space+ "encoding=\"UTF-8\"" space+ "?>"
{ xml_doctype "1.0" "" lexbuf }
| "<?xml" ([^'?']|'?'[^'>'])* "?>"
{ Format.eprintf "[Xml warning] prolog ignored@\n";
{ dprintf debug "[Xml warning] prolog ignored@.";
xml_doctype "1.0" "" lexbuf }
| _
{ parse_error "wrong prolog" }
......@@ -103,14 +105,14 @@ and elements group_stack element_stack = parse
| "</" (ident as celem) space* '>'
{ match group_stack with
| [] ->
Format.eprintf
"[Xml warning] unexpected closing Xml element `%s'@\n"
dprintf debug
"[Xml warning] unexpected closing Xml element `%s'@."
celem;
elements group_stack element_stack lexbuf
| (elem,att,stack)::g ->
if celem <> elem then
Format.eprintf
"[Xml warning] Xml element `%s' closed by `%s'@\n"
dprintf debug
"[Xml warning] Xml element `%s' closed by `%s'@."
elem celem;
let e = {
name = elem;
......@@ -120,13 +122,13 @@ and elements group_stack element_stack = parse
in elements g (e::stack) lexbuf
}
| '<'
{ Format.eprintf "[Xml warning] unexpected '<'@\n";
{ dprintf debug "[Xml warning] unexpected '<'@.";
elements group_stack element_stack lexbuf }
| eof
{ match group_stack with
| [] -> element_stack
| (elem,_,_)::_ ->
Format.eprintf "[Xml warning] unclosed Xml element `%s'@\n" elem;
dprintf debug "[Xml warning] unclosed Xml element `%s'@." elem;
pop_all group_stack element_stack
}
| _ as c
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment