Commit c2d5eaf2 authored by Pietro Abate's avatar Pietro Abate

[r2003-06-09 09:09:58 by cvscast] Synchro on errors -- Alain

Original author: cvscast
Date: 2003-06-09 09:10:55+00:00
parent acecd660
split:
ocaml unix.cma bench.ml split 0,10,50,100,500,1000 \
split*.cd split*.q split*.xsl \
split*.cd split*.xsl \
| tee split.results
addrbook:
......
......@@ -47,11 +47,11 @@ let args = List.map int_of_string (split ',' args)
let sp = sprintf
let langs =
[
"CDuce", ".cd",
(* "CDuce PXP", ".cd",
(fun script xml ->
sp "%s --pxp --quiet %s --arg %s" cduce_cmd script xml);
sp "%s --pxp --quiet %s --arg %s" cduce_cmd script xml); *)
"CDuce+expat", ".cd",
"CDuce expat", ".cd",
(fun script xml ->
sp "%s --expat --quiet %s --arg %s" cduce_cmd script xml);
......@@ -74,7 +74,7 @@ let langs =
let pr = printf
let rep = 1
let rep = 3
let time s =
let s = sp "%s -p %s 2>&1" time_cmd s in
......
......@@ -199,9 +199,9 @@ let run rule ppf ppf_err input =
try rule input
with
| Stdpp.Exc_located (_, (Location _ as e)) ->
Parser.sync input; raise e
Parser.sync (); raise e
| Stdpp.Exc_located ((i,j), e) ->
Parser.sync input; raise_loc i j e
Parser.sync (); raise_loc i j e
in
phrases ppf p;
true
......
......@@ -497,14 +497,15 @@ and expr = Grammar.Entry.parse expr
and prog = Grammar.Entry.parse prog
and top_phrases = Grammar.Entry.parse top_phrases
let rec sync s =
match Stream.next s with
| ';' ->
(match Stream.next s with
| ';' -> ()
| _ -> sync s)
| _ -> sync s
let sync s =
try sync s with Stream.Failure -> ()
let sync () =
match !Wlexer.lexbuf with
| None -> ()
| Some lb ->
let rec aux () =
match !Wlexer.last_tok with
| ("",";;") | ("EOI","") -> ()
| _ ->
Wlexer.last_tok := Wlexer.token Wlexer.latin1_engine lb;
aux ()
in
aux ()
......@@ -5,4 +5,4 @@ val pat : char Stream.t -> Ast.ppat
val prog : char Stream.t -> Ast.pmodule_item list
val top_phrases : char Stream.t -> Ast.pmodule_item list
val sync : char Stream.t -> unit
val sync : unit -> unit
......@@ -246,7 +246,7 @@ let rec token engine lexbuf =
"EOI","" )
| 8 -> (
# 126 "parser/wlexer.mll"
Printf.eprintf "XXX\n"; error
error
(Lexing.lexeme_start lexbuf) (Lexing.lexeme_end lexbuf)
(Illegal_character ((Lexing.lexeme lexbuf).[0])) )
| _ -> failwith "lexing: empty token [token]"
......@@ -347,18 +347,25 @@ and parse_hexa_char engine lexbuf =
let delta_loc = ref 0
let set_delta_loc dl = delta_loc := dl
(* For synchronization on errors in the toplevel ... *)
let lexbuf = ref None
let last_tok = ref ("","")
let lexer_func_of_wlex lexfun lexengine cs =
let dl = !delta_loc in
delta_loc := 0;
let lb =
Lexing.from_function
(fun s n ->
try s.[0] <- Stream.next cs; 1 with Stream.Failure -> 0)
try s.[0] <- Stream.next cs; 1
with Stream.Failure -> 0)
in
lexbuf := Some lb;
let next () =
let tok = lexfun lexengine lb in
let loc = (Lexing.lexeme_start lb + dl,
Lexing.lexeme_end lb + dl) in
last_tok := tok;
(tok, loc)
in
Token.make_stream_and_location next
......
......@@ -123,7 +123,7 @@ rule token = parse
| eof
{ "EOI","" }
| _
{ Printf.eprintf "XXX\n"; error
{ error
(Lexing.lexeme_start lexbuf) (Lexing.lexeme_end lexbuf)
(Illegal_character ((Lexing.lexeme lexbuf).[0])) }
......@@ -202,18 +202,26 @@ and parse_hexa_char = parse
let delta_loc = ref 0
let set_delta_loc dl = delta_loc := dl
(* For synchronization on errors in the toplevel ... *)
(* Issue: file inclusion *)
let lexbuf = ref None
let last_tok = ref ("","")
let lexer_func_of_wlex lexfun lexengine cs =
let dl = !delta_loc in
delta_loc := 0;
let lb =
Lexing.from_function
(fun s n ->
try s.[0] <- Stream.next cs; 1 with Stream.Failure -> 0)
try s.[0] <- Stream.next cs; 1
with Stream.Failure -> 0)
in
lexbuf := Some lb;
let next () =
let tok = lexfun lexengine lb in
let loc = (Lexing.lexeme_start lb + dl,
Lexing.lexeme_end lb + dl) in
last_tok := tok;
(tok, loc)
in
Token.make_stream_and_location next
......
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