Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
c2d5eaf2
Commit
c2d5eaf2
authored
Oct 05, 2007
by
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
acecd660
Changes
7
Hide whitespace changes
Inline
Side-by-side
benchmarks/Makefile
View file @
c2d5eaf2
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
:
...
...
benchmarks/bench.ml
View file @
c2d5eaf2
...
...
@@ -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
...
...
driver/cduce.ml
View file @
c2d5eaf2
...
...
@@ -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
...
...
parser/parser.ml
View file @
c2d5eaf2
...
...
@@ -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
()
parser/parser.mli
View file @
c2d5eaf2
...
...
@@ -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
:
uni
t
->
unit
parser/wlexer.ml
View file @
c2d5eaf2
...
...
@@ -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
...
...
parser/wlexer.mll
View file @
c2d5eaf2
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment