Commit 864089fd authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-05-26 20:59:50 by cvscast] bug for file inclusion

Original author: cvscast
Date: 2003-05-26 20:59:50+00:00
parent 6a782c4d
...@@ -93,6 +93,10 @@ let char_list loc s = ...@@ -93,6 +93,10 @@ let char_list loc s =
let include_stack = ref [] let include_stack = ref []
let protect_exn f g =
try let x = f () in g (); x
with e -> g (); raise e
EXTEND EXTEND
GLOBAL: top_phrases prog expr pat regexp const; GLOBAL: top_phrases prog expr pat regexp const;
...@@ -122,14 +126,17 @@ EXTEND ...@@ -122,14 +126,17 @@ EXTEND
if List.mem s !include_stack then [] if List.mem s !include_stack then []
else ( else (
include_stack := s :: !include_stack; include_stack := s :: !include_stack;
let chan = open_in s in
Location.push_source (`File s); Location.push_source (`File s);
let input = Stream.of_channel chan in protect_exn
let l = Grammar.Entry.parse prog input in (fun () ->
close_in chan; let chan = open_in s in
Location.pop_source (); let input = Stream.of_channel chan in
include_stack := List.tl !include_stack; let l = Grammar.Entry.parse prog input in
l close_in chan;
l)
(fun () ->
Location.pop_source ();
include_stack := List.tl !include_stack)
) )
] | ] |
[ e = expr -> [ mk loc (EvalStatement e) ] [ e = expr -> [ mk loc (EvalStatement e) ]
......
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