Commit c7588b98 authored by bguillaum's avatar bguillaum

localize "File not found" in include directives

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@6711 7838e531-6607-4d57-9587-6c381814729c
parent a409d328
......@@ -28,7 +28,7 @@ INFO = @INFO@
OCAMLFIND_DIR=`ocamlfind printconf destdir`
VERSION = 0.9.4
VERSION = 0.9.5
cleanup:
rm -rf *.cmo *.cmx *.cmi *.annot *.o *.*~
......
......@@ -112,7 +112,7 @@ module Ast = struct
*)
type module_or_include =
| Modul of modul
| Includ of string
| Includ of (string * Loc.t)
type grs_with_include = {
domain_wi: domain;
......
......@@ -105,7 +105,7 @@ module Ast : sig
*)
type module_or_include =
| Modul of modul
| Includ of string
| Includ of (string * Loc.t)
type grs_with_include = {
domain_wi: domain;
......
......@@ -141,8 +141,10 @@ module_or_include_list:
module_or_include:
| m = grew_module { Ast.Modul m }
| INCLUDE file = STRING { Ast.Includ file }
| INCLUDE sub = subfile SEMIC { Ast.Includ sub }
subfile:
| f = STRING { localize f }
/*=============================================================================================*/
/* */
......
open Grew_utils
open Grew_ast
module Grew_parser = struct
......@@ -48,7 +49,7 @@ module Grew_parser = struct
with Sys_error msg-> raise (Parse_error msg)
let parse_file_to_module_list file =
let parse_file_to_module_list loc file =
try
let in_ch = open_in file in
let to_parse = Lexing.from_channel in_ch in
......@@ -69,7 +70,7 @@ module Grew_parser = struct
raise (Parse_error (Printf.sprintf "Syntax error\nFile %s\nLine %d\n%s\n%!" file cp.Lexing.pos_lnum msg))
| err -> raise (Parse_error (Printexc.to_string err))
end
with Sys_error msg -> raise (Parse_error msg)
with Sys_error msg -> raise (Parse_error(Printf.sprintf "Sys error: %s%s%!" msg (Loc.to_string loc)))
(**
......@@ -82,12 +83,12 @@ module Grew_parser = struct
let rec flatten_modules = function
| [] -> []
| Ast.Modul m :: tail -> m :: (flatten_modules tail)
| Ast.Includ inc_file :: tail ->
| Ast.Includ (inc_file,loc) :: tail ->
let sub_file =
if Filename.is_relative inc_file
then Filename.concat (Filename.dirname main_file) inc_file
else inc_file in
(flatten_modules (parse_file_to_module_list sub_file))
(flatten_modules (parse_file_to_module_list loc sub_file))
@ (flatten_modules tail) in
{
Ast.domain = grs_with_includes.Ast.domain_wi;
......
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