Commit cdaa4b4f authored by bguillaum's avatar bguillaum

make domain optional in GRS

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@9066 7838e531-6607-4d57-9587-6c381814729c
parent 48b71885
......@@ -362,13 +362,13 @@ module Ast = struct
type domain_wi = Dom of domain | Dom_file of string
type grs_wi = {
domain_wi: domain_wi;
domain_wi: domain_wi option;
modules_wi: module_or_include list;
sequences_wi: sequence list;
}
type grs = {
domain: domain;
domain: domain option;
modules: modul list;
sequences: sequence list;
}
......@@ -379,6 +379,6 @@ module Ast = struct
edges: edge list;
}
let empty_grs = { domain = empty_domain; modules = []; sequences= [] }
let empty_grs = { domain = None; modules = []; sequences= [] }
end (* module Ast *)
......@@ -202,14 +202,14 @@ module Ast : sig
type domain_wi = Dom of domain | Dom_file of string
type grs_wi = {
domain_wi: domain_wi;
domain_wi: domain_wi option;
modules_wi: module_or_include list;
sequences_wi: sequence list;
}
(* a GRS: graph rewriting system *)
type grs = {
domain: domain;
domain: domain option;
modules: modul list;
sequences: sequence list;
}
......
......@@ -252,17 +252,14 @@ module Grs = struct
| s::tail -> loop (s.Sequence.name :: already_defined) tail in
loop [] t.sequences
let domain_build= function
| {Ast.label_domain=[]; feature_domain=[]} -> None
| ast_domain -> Some (
Domain.build
let domain_build ast_domain =
Domain.build
(Label_domain.build ast_domain.Ast.label_domain)
(Feature_domain.build ast_domain.Ast.feature_domain)
)
let build filename =
let ast = Loader.grs filename in
let domain = domain_build ast.Ast.domain in
let domain = match ast.Ast.domain with None -> None | Some ast_dom -> Some (domain_build ast_dom) in
let modules = List.map (Modul.build ?domain) ast.Ast.modules in
let grs = {domain; sequences = List.map (Sequence.build modules) ast.Ast.sequences; modules; ast; filename} in
check grs;
......
......@@ -93,7 +93,7 @@ module Grs: sig
val sequence_names: t -> string list
val domain_build: Ast.domain -> Domain.t option
val domain_build: Ast.domain -> Domain.t
(** [build filename] returns the GRS defined in the file [filename] *)
val build: string -> t
......
......@@ -464,7 +464,11 @@ module Html_doc = struct
let domain = Filename.concat output_dir "domain.html" in
let domain_out_ch = open_out domain in
output_string domain_out_ch (domain_text ~corpus ast.Ast.domain);
begin
match ast.Ast.domain with
| Some dom -> output_string domain_out_ch (domain_text ~corpus dom)
| None -> output_string domain_out_ch "No domain defined"
end;
close_out domain_out_ch;
(** Modules + rules **)
......
......@@ -66,8 +66,9 @@ module Loader = struct
let grs main_file =
let grs_wi = parse_file_to_grs_wi main_file in
let domain = match grs_wi.Ast.domain_wi with
| Ast.Dom d -> d
| Ast.Dom_file file -> domain file in
| None -> None
| Some (Ast.Dom d) -> Some d
| Some (Ast.Dom_file file) -> Some (domain file) in
let rec flatten_modules current_file = function
| [] -> []
| Ast.Modul m :: tail ->
......
......@@ -220,16 +220,16 @@ domain:
/* GREW GRAPH REWRITING SYSTEM */
/*=============================================================================================*/
grs_wi:
| d=domain m=module_or_include_list s=option(sequences) EOF
| d=option(domain) m=module_or_include_list s=option(sequences) EOF
{
{ Ast.domain_wi=Ast.Dom d;
{ Ast.domain_wi=(match d with Some dom -> Some (Ast.Dom dom) | None -> None);
modules_wi=m;
sequences_wi=match s with Some seq -> seq | None -> [];
}
}
| DOMAIN file=STRING m=module_or_include_list s=option(sequences) EOF
{
{ Ast.domain_wi=Ast.Dom_file file;
{ Ast.domain_wi= Some (Ast.Dom_file file);
modules_wi=m;
sequences_wi=match s with Some seq -> seq | None -> [];
}
......
......@@ -108,7 +108,6 @@ module Label_domain = struct
}
type t = string array * style array
let empty = ([||],[||])
(** The [default] style value *)
let default = { text="UNSET"; bottom=false; color=None; bgcolor=None; line=Solid }
......@@ -176,8 +175,6 @@ module Feature_domain = struct
type t = feature_spec list
let empty = []
let is_defined feature_name feature_domain =
List.exists (function
| Closed (fn,_) when fn = feature_name -> true
......@@ -265,8 +262,6 @@ module Domain = struct
let build ld fd = (ld, fd)
let empty = (Label_domain.empty, Feature_domain.empty)
let feature_names (_, feature_domain) = Feature_domain.feature_names feature_domain
let is_open_feature ?domain name = match domain with
......
......@@ -66,8 +66,7 @@ module Massoc_pid : S with type key = Pid.t
(* ================================================================================ *)
module Label_domain : sig
type t
val empty : t
(* [decl] is the type for a label declaration: the name and a list of display options *)
type decl = string * string list
......@@ -83,8 +82,6 @@ module Feature_domain: sig
type t
val empty: t
val build: feature_spec list -> t
(** [sub domain fn1 fn2] returns [true] iff the domain of [fn1] is a subset if the domain of [fn2]. *)
......@@ -100,8 +97,6 @@ module Domain : sig
val build: Label_domain.t -> Feature_domain.t -> t
val empty: t
val feature_names: t -> string list
(** [is_open_feature domain feature_name] returns [true] iff no domain is set or if [feature_name] is defined to be open in the current domain. *)
......
......@@ -56,13 +56,9 @@ let handle ?(name="") ?(file="No file defined") fct () =
module Domain = struct
type t = Grew_types.Domain.t
let empty = Grew_types.Domain.empty
let load filename =
let ast = Grew_loader.Loader.domain filename in
match Grew_grs.Grs.domain_build ast with
| Some dom -> dom
| None -> raise (Bug ("[Domain.load] empty domain", None))
Grew_grs.Grs.domain_build ast
let feature_names domain = handle ~name:"feature_names" (fun () -> Grew_types.Domain.feature_names domain) ()
end
......
......@@ -41,7 +41,6 @@ exception Bug of string * Loc.t option
(* ==================================================================================================== *)
module Domain : sig
type t
val empty: t
val load: string -> t
val feature_names: t -> string list
end
......
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