Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grew
libcaml-grew
Commits
e5f6515a
Commit
e5f6515a
authored
Aug 18, 2017
by
Bruno Guillaume
Browse files
make a universal [Grs.load] file: try new syntax and then old syntax in case of failure
parent
bf1a0dac
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/grew_grs.ml
View file @
e5f6515a
...
...
@@ -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
src/grew_grs.mli
View file @
e5f6515a
...
...
@@ -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
src/libgrew.ml
View file @
e5f6515a
...
...
@@ -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
=
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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