Commit a843ce53 authored by bguillaum's avatar bguillaum

improve search for a sequence:

1) search for the sequence with the requested name
2) search for the module with the requested name
3) select the first sequence defined in the GRS file

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@8957 7838e531-6607-4d57-9587-6c381814729c
parent 5a43e342
......@@ -263,19 +263,21 @@ module Grs = struct
check grs;
grs
(* compute the list of modules to apply for a requested sentence *)
let modules_of_sequence grs sequence =
let module_names =
try
let seq = List.find (fun s -> s.Sequence.name = sequence) grs.sequences in
List.map (fun name -> List.find (fun m -> m.Modul.name=name) grs.modules) seq.Sequence.def
with Not_found ->
try
let seq = List.find (fun s -> s.Sequence.name = sequence) grs.sequences in
seq.Sequence.def
with Not_found -> [sequence] in (* a module name can be used as a singleton sequence *)
List.map
(fun name ->
try List.find (fun m -> m.Modul.name=name) grs.modules
with Not_found -> Log.fcritical "No sequence or module named '%s'" name
)
module_names
let modul = List.find (fun m -> m.Modul.name=sequence) grs.modules in
Log.fwarning "\"%s\" is a module but not a senquence, only this module is used" sequence; [modul]
with Not_found ->
match grs.sequences with
| head::_ ->
Log.fwarning "No sequence and no module named \"%s\", the first sequence \"%s\" is used" sequence head.Sequence.name;
List.map (fun name -> List.find (fun m -> m.Modul.name=name) grs.modules) head.Sequence.def
| _ -> Error.run "No sequence defined and no module named \"%s\", cannot go on" sequence
let rewrite grs sequence graph =
let instance = Instance.from_graph graph in
......
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