Commit e5f6515a authored by Bruno Guillaume's avatar Bruno Guillaume

make a universal [Grs.load] file: try new syntax and then old syntax in case of failure

parent bf1a0dac
......@@ -226,8 +226,6 @@ module Grs = struct
check_strategy strat t
) t.strategies
let domain_build ast_domain =
Domain.build
(Label_domain.build ast_domain.Ast.label_domain)
......@@ -472,28 +470,6 @@ module Grs = struct
) grs.modules
end (* module Grs *)
module New_grs = struct
type decl =
......@@ -534,8 +510,7 @@ module New_grs = struct
let domain t = t.domain
let load filename =
let ast = Loader.new_grs filename in
let from_ast filename ast =
let feature_domains = List_.opt_map
(fun x -> match x with
......@@ -576,6 +551,8 @@ module New_grs = struct
decls;
}
let load filename = from_ast filename (Loader.new_grs filename)
(* The type [pointed] is a zipper style data structure for resolving names x.y.z *)
type pointed =
| Top of decl list
......@@ -921,3 +898,21 @@ module New_grs = struct
end
module Univ_grs = struct
let load file =
let new_ast =
try
let ast = Loader.new_grs file in
Log.finfo "[Univ_grs.load] SUCCEED to load file \"%s\" with NEW syntax" file;
ast
with exc_new ->
Log.finfo "[Univ_grs.load] FAILED to load file \"%s\" with NEW syntax: exc=\"%s\"" file (Printexc.to_string exc_new);
try
let ast = New_ast.convert (Loader.grs file) in
Log.finfo "[Univ_grs.load] SUCCEED to load file \"%s\" with OLD syntax" file;
ast
with exc_old ->
Log.finfo "[Univ_grs.load] FAILED to load file \"%s\" with OLD syntax: exc=\"%s\"" file (Printexc.to_string exc_old);
raise exc_new in
New_grs.from_ast file new_ast
end
\ No newline at end of file
......@@ -123,4 +123,8 @@ module New_grs : sig
val det_rew_display: t -> string -> G_graph.t -> Libgrew_types.rew_display
val get_strat_list: t -> string list
end
module Univ_grs : sig
val load: string -> New_grs.t
end
\ No newline at end of file
......@@ -282,7 +282,7 @@ module New_grs = struct
let load file =
handle ~name:"New_grs.load" ~file
(fun () ->
Grew_grs.New_grs.load file
Grew_grs.Univ_grs.load file
) ()
let dump grs =
......
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