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

[r2003-11-20 13:33:33 by afrisch] Bug fix: file name in error messages for included files

Original author: afrisch
Date: 2003-11-20 13:33:33+00:00
parent d2518722
......@@ -345,17 +345,11 @@ let catch_exn ppf_err exn =
Format.fprintf ppf_err "@."
let parse rule input =
try Some (rule input)
with
| Stdpp.Exc_located (_, (Location _ as e)) ->
Parser.sync (); raise e
| Stdpp.Exc_located ((i,j), e) ->
Parser.sync (); raise_loc i j e
try Parser.localize_exn (fun () -> rule input)
with e -> Parser.sync (); raise e
let run rule ppf ppf_err input =
try match parse rule input with
| Some phs -> phrases ppf phs; true
| None -> false
try phrases ppf (parse rule input); true
with exn -> catch_exn ppf_err exn; false
let script = run Parser.prog
......
......@@ -75,6 +75,13 @@ let protect_exn f g =
try let x = f () in g (); x
with e -> g (); raise e
let localize_exn f =
try f ()
with
| Stdpp.Exc_located (_, (Location _ as e)) -> raise e
| Stdpp.Exc_located ((i,j), e) -> raise_loc i j e
let is_fun_decl =
Grammar.Entry.of_parser gram "[is_fun_decl]"
(fun strm ->
......@@ -155,7 +162,7 @@ EXTEND
protect_exn
(fun () ->
let input = Stream.of_channel chan in
Grammar.Entry.parse prog input)
localize_exn (fun () -> Grammar.Entry.parse prog input))
(fun () -> close_in chan))
(fun () ->
Ulexer.enc := saved_enc;
......
......@@ -6,7 +6,7 @@ val prog : char Stream.t -> Ast.pmodule_item list
val top_phrases : char Stream.t -> Ast.pmodule_item list
val sync : unit -> unit
val localize_exn: (unit -> 'a) -> 'a
(* Hooks to extend the syntax *)
......
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