Commit 84952203 authored by Pietro Abate's avatar Pietro Abate
Browse files

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