Commit 8222ad4d authored by gerd's avatar gerd

Problems with Lexing under 3.07 fixed


git-svn-id: https://godirepo.camlcity.org/svn/lib-pxp/trunk@657 dbe99aee-44db-0310-b2b3-d33182c8eb97
parent 789d941a
......@@ -8,9 +8,9 @@ OBJ = pxp_lexing.cmo pxp_type_anchor.cmo \
pxp_lex_aux.cmo pxp_lexers.cmo \
pxp_lib.cmo pxp_aux.cmo pxp_reader.cmo \
pxp_dfa.cmo \
pxp_entity.cmo pxp_dtd.cmo pxp_document.cmo \
pxp_entity.cmo pxp_dtd.cmo \
pxp_entity_manager.cmo \
pxp_types.cmo \
pxp_types.cmo pxp_document.cmo \
pxp_core_parser.cmo pxp_tree_parser.cmo pxp_ev_parser.cmo \
pxp_dtd_parser.cmo \
pxp_yacc.cmo pxp_marshal.cmo pxp_codewriter.cmo
......
(* $Id: pxp_aux.ml,v 1.17 2003/06/20 15:14:13 gerd Exp $
(* $Id: pxp_aux.ml,v 1.18 2003/11/04 22:45:07 gerd Exp $
* ----------------------------------------------------------------------
* PXP: The polymorphic XML parser for Objective Caml.
* Copyright by Gerd Stolpmann. See LICENSE for details.
......@@ -124,8 +124,7 @@ let rec expand_attvalue_with_rec_check lexbuf l lexerset dtd entities norm_crlf
raise
(WF_error
("Attribute value contains character '<' literally"));
if Lexing.lexeme_start lexbuf = 0 &&
Lexing.lexeme_end lexbuf = l then
if Pxp_lexing.lexeme_len lexbuf = l then
raise Quick_exit
else
let x = Lexing.lexeme lexbuf in
......@@ -788,6 +787,9 @@ let write_data_string ~(from_enc:rep_encoding) ~to_enc os content =
* History:
*
* $Log: pxp_aux.ml,v $
* Revision 1.18 2003/11/04 22:45:07 gerd
* Problems with Lexing under 3.07 fixed
*
* Revision 1.17 2003/06/20 15:14:13 gerd
* Introducing symbolic warnings, expressed as polymorphic
* variants
......
(* $Id: pxp_entity.ml,v 1.23 2003/06/20 15:14:14 gerd Exp $
(* $Id: pxp_entity.ml,v 1.24 2003/11/04 22:45:07 gerd Exp $
* ----------------------------------------------------------------------
* PXP: The polymorphic XML parser for Objective Caml.
* Copyright by Gerd Stolpmann. See LICENSE for details.
......@@ -205,8 +205,7 @@ let update_content_lines v tok =
count_lines v.linecount (Lexing.lexeme v.lexbuf);
update_lines v;
| _ ->
v.column <- v.column + Lexing.lexeme_end v.lexbuf
- Lexing.lexeme_start v.lexbuf
v.column <- v.column + Pxp_lexing.lexeme_len v.lexbuf
;;
let update_lines_within_tag v tok =
......@@ -224,8 +223,7 @@ let update_lines_within_tag v tok =
v.line <- v.line + 1;
v.column <- 0;
| _ ->
v.column <- v.column + Lexing.lexeme_end v.lexbuf
- Lexing.lexeme_start v.lexbuf
v.column <- v.column + Pxp_lexing.lexeme_len v.lexbuf
;;
let update_other_lines v tok =
......@@ -1317,6 +1315,9 @@ end
* History:
*
* $Log: pxp_entity.ml,v $
* Revision 1.24 2003/11/04 22:45:07 gerd
* Problems with Lexing under 3.07 fixed
*
* Revision 1.23 2003/06/20 15:14:14 gerd
* Introducing symbolic warnings, expressed as polymorphic
* variants
......
(* $Id: pxp_lexing.mli,v 1.1 2002/03/13 22:25:51 gerd Exp $
(* $Id: pxp_lexing.mli,v 1.2 2003/11/04 22:45:07 gerd Exp $
* ----------------------------------------------------------------------
*
*)
......@@ -20,12 +20,15 @@ val lexeme : lexbuf -> string
val lexeme_char : lexbuf -> int -> char
val lexeme_start : lexbuf -> int
(* val lexeme_start : lexbuf -> int *) (* Removed because of wlex problems *)
val lexeme_end : lexbuf -> int
(* val lexeme_end : lexbuf -> int *) (* Removed because of wlex problems *)
(* Extensions: *)
val lexeme_len : lexbuf -> int
(* = String.length(lexeme lexbuf) *)
val from_string_inplace : string -> Lexing.lexbuf
(* Similar to Lexing.from_string, but does not copy the passed string
* intially
......@@ -47,6 +50,9 @@ val sub_lexeme : Lexing.lexbuf -> int -> int -> string
* History:
*
* $Log: pxp_lexing.mli,v $
* Revision 1.2 2003/11/04 22:45:07 gerd
* Problems with Lexing under 3.07 fixed
*
* Revision 1.1 2002/03/13 22:25:51 gerd
* Initial revision.
*
......
(* $Id: pxp_lexing.mlp,v 1.8 2003/10/03 21:13:26 gerd Exp $
(* $Id: pxp_lexing.mlp,v 1.9 2003/11/04 22:45:07 gerd Exp $
* ----------------------------------------------------------------------
* PXP: The polymorphic XML parser for Objective Caml.
* Copyright by Gerd Stolpmann. See LICENSE for details.
......@@ -27,6 +27,9 @@ let lexeme_char = Lexing.lexeme_char
let lexeme_start = Lexing.lexeme_start
let lexeme_end = Lexing.lexeme_end
let lexeme_len lexbuf =
lexbuf.lex_curr_pos - lexbuf.lex_start_pos
let from_string_inplace s =
(* avoids copying s *)
let lb = from_string "" in
......@@ -79,6 +82,9 @@ let sub_lexeme lexbuf k l =
* History:
*
* $Log: pxp_lexing.mlp,v $
* Revision 1.9 2003/11/04 22:45:07 gerd
* Problems with Lexing under 3.07 fixed
*
* Revision 1.8 2003/10/03 21:13:26 gerd
* Another bugfix
*
......
(* $Id: pxp_tree_parser.ml,v 1.5 2003/06/29 15:44:30 gerd Exp $
(* $Id: pxp_tree_parser.ml,v 1.6 2003/11/04 22:45:07 gerd Exp $
* ----------------------------------------------------------------------
* PXP: The polymorphic XML parser for Objective Caml.
* Copyright by Gerd Stolpmann. See LICENSE for details.
......@@ -576,6 +576,9 @@ let call_tree_parser ~configuration:cfg
mgr # pop_entity_until en;
if en # is_open then ignore(en # close_entity);
raise (At(pos, Netconversion.Malformed_code))
| (Invalid_argument _ | Assert_failure(_,_,_) | Match_failure(_,_,_)
as error) ->
raise error (* Re-raise immediately for simpler debugging *)
| error ->
let pos = mgr # position_string in
mgr # pop_entity_until en;
......@@ -768,6 +771,9 @@ let extract_dtd_from_document_entity cfg src =
* History:
*
* $Log: pxp_tree_parser.ml,v $
* Revision 1.6 2003/11/04 22:45:07 gerd
* Problems with Lexing under 3.07 fixed
*
* Revision 1.5 2003/06/29 15:44:30 gerd
* New entry flag: `Val_mode_dtd
*
......
(* $Id: pxp_lex_content.src,v 1.10 2002/08/03 17:56:27 gerd Exp $
(* $Id: pxp_lex_content.src,v 1.11 2003/11/04 22:45:13 gerd Exp $
* ----------------------------------------------------------------------
*
*)
......@@ -24,7 +24,7 @@ rule scan_content = parse
{ Comment_begin dummy_entity, Content_comment }
| '<' '/'? name
(* One rule for Tag_beg and Tag_end saves transitions. *)
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
if Lexing.lexeme_char lexbuf 1 = '/' then
Tag_end (Pxp_lexing.sub_lexeme lexbuf 2 (l-2), dummy_entity),
Within_tag_entry
......@@ -33,7 +33,7 @@ rule scan_content = parse
Within_tag_entry
}
| "<![CDATA[" cdata_string "]]>"
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
Cdata (Pxp_lexing.sub_lexeme lexbuf 9 (l-12)), Content }
| "<!"
{ raise (WF_error "Declaration either malformed or not allowed in this context")
......@@ -42,13 +42,13 @@ rule scan_content = parse
{ raise (WF_error ("The left angle bracket '<' must be written as '&lt;'"))
}
| "&#" ascii_digit+ ";"
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
CRef (int_of_string (Pxp_lexing.sub_lexeme lexbuf 2 (l-3))), Content }
| "&#x" ascii_hexdigit+ ";"
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
CRef (int_of_string ("0x" ^ Pxp_lexing.sub_lexeme lexbuf 3 (l-4))), Content }
| "&" name ";"
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
ERef (Pxp_lexing.sub_lexeme lexbuf 1 (l-2)), Content }
| "&"
{ raise (WF_error ("The ampersand '&' must be written as '&amp;'"))
......@@ -94,6 +94,9 @@ rule scan_content = parse
* History:
*
* $Log: pxp_lex_content.src,v $
* Revision 1.11 2003/11/04 22:45:13 gerd
* Problems with Lexing under 3.07 fixed
*
* Revision 1.10 2002/08/03 17:56:27 gerd
* Support for event-based parsing of attribute values.
*
......
(* $Id: pxp_lex_within_tag.src,v 1.8 2002/08/03 17:56:27 gerd Exp $
(* $Id: pxp_lex_within_tag.src,v 1.9 2003/11/04 22:45:13 gerd Exp $
* ----------------------------------------------------------------------
*
*)
......@@ -28,14 +28,14 @@ rule scan_within_tag = parse
| '='
{ tok_Eq__Within_tag }
| '"' character_except_quot* '"'
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
let v = Pxp_lexing.sub_lexeme lexbuf 1 (l-2) in
Attval v, Within_tag }
| '"'
{ raise (WF_error ("Cannot find the second quotation mark"))
}
| "'" character_except_apos* "'"
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
let v = Pxp_lexing.sub_lexeme lexbuf 1 (l-2) in
Attval v, Within_tag }
| "'"
......@@ -91,6 +91,9 @@ and scan_tag_eb = parse
* History:
*
* $Log: pxp_lex_within_tag.src,v $
* Revision 1.9 2003/11/04 22:45:13 gerd
* Problems with Lexing under 3.07 fixed
*
* Revision 1.8 2002/08/03 17:56:27 gerd
* Support for event-based parsing of attribute values.
*
......
(* $Id: lex.src,v 1.3 2002/10/19 16:56:39 gerd Exp $
(* $Id: lex.src,v 1.4 2003/11/04 22:45:10 gerd Exp $
* ----------------------------------------------------------------------
*
*)
......@@ -115,7 +115,7 @@ detect_xml_pi = parse
scan_pi_string = parse
pi_string "?>"
{ let len =
Pxp_lexing.lexeme_end lexbuf - Pxp_lexing.lexeme_start lexbuf in
Pxp_lexing.lexeme_len lexbuf in
Some (Pxp_lexing.sub_lexeme lexbuf 0 (len-2))
}
| ""
......@@ -461,7 +461,7 @@ scan_content = parse
{ Comment_begin dummy_entity, (Comment Content) }
| '<' '/'? name
(* One rule for Tag_beg and Tag_end saves transitions. *)
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
if Lexing.lexeme_char lexbuf 1 = '/' then
Tag_end (Pxp_lexing.sub_lexeme lexbuf 2 (l-2), dummy_entity),
Within_tag_entry
......@@ -470,7 +470,7 @@ scan_content = parse
Within_tag_entry
}
| "<![CDATA[" cdata_string "]]>"
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
Cdata (Pxp_lexing.sub_lexeme lexbuf 9 (l-12)), Content }
| "<!"
{ raise (WF_error "Declaration either malformed or not allowed in this context")
......@@ -479,13 +479,13 @@ scan_content = parse
{ raise (WF_error ("The left angle bracket '<' must be written as '&lt;'"))
}
| "&#" ascii_digit+ ";"
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
CRef (int_of_string (Pxp_lexing.sub_lexeme lexbuf 2 (l-3))), Content }
| "&#x" ascii_hexdigit+ ";"
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
CRef (int_of_string ("0x" ^ Pxp_lexing.sub_lexeme lexbuf 3 (l-4))), Content }
| "&" name ";"
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
ERef (Pxp_lexing.sub_lexeme lexbuf 1 (l-2)), Content }
| "&"
{ raise (WF_error ("The ampersand '&' must be written as '&amp;'"))
......@@ -547,14 +547,14 @@ scan_within_tag = parse
| '='
{ tok_Eq__Within_tag }
| '"' char_but_quot* '"'
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
let v = Pxp_lexing.sub_lexeme lexbuf 1 (l-2) in
Attval v, Within_tag }
| '"'
{ raise (WF_error ("Cannot find the second quotation mark"))
}
| "'" char_but_apos* "'"
{ let l = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in
{ let l = Pxp_lexing.lexeme_len lexbuf in
let v = Pxp_lexing.sub_lexeme lexbuf 1 (l-2) in
Attval v, Within_tag }
| "'"
......@@ -804,6 +804,9 @@ scan_for_crlf = parse
* History:
*
* $Log: lex.src,v $
* Revision 1.4 2003/11/04 22:45:10 gerd
* Problems with Lexing under 3.07 fixed
*
* Revision 1.3 2002/10/19 16:56:39 gerd
* Added comment
*
......
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