Commit 255dd123 authored by bguillaum's avatar bguillaum

separate load_grs / build_html_doc

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@8107 7838e531-6607-4d57-9587-6c381814729c
parent b9601263
FILES_DEP = grew_utils grew_ast grew_fs grew_edge grew_node grew_graph grew_types grew_command grew_rule grew_grs grew_html
FILES_ML = $(FILES_DEP:%=%.ml)
FILES_MLI = $(FILES_DEP:%=%.mli)
PRE_FILES_DEP = grew_utils grew_ast
PRE_FILES_CMO = $(PRE_FILES_DEP:%=%.cmo)
PRE_FILES_CMX = $(PRE_FILES_DEP:%=%.cmx)
POST_FILES_DEP = grew_fs grew_edge grew_node grew_graph grew_types grew_command grew_rule grew_grs grew_html
POST_FILES_CMO = $(POST_FILES_DEP:%=%.cmo)
POST_FILES_CMX = $(POST_FILES_DEP:%=%.cmx)
FILES_DEP = $(PRE_FILES_DEP) $(POST_FILES_DEP)
FILES_CMI = $(FILES_DEP:%=%.cmi)
FILES_CMO = $(FILES_DEP:%=%.cmo)
FILES_CMX = $(FILES_DEP:%=%.cmx)
PARSER_DEP = parser_global lexer gr_grs_parser grew_parser
PARSER_ML = $(PARSER_DEP:%=%.ml)
PARSER_MLI = $(PARSER_DEP:%=%.mli)
PARSER_CMI = $(PARSER_DEP:%=%.cmi)
PARSER_CMO = $(PARSER_DEP:%=%.cmo)
PARSER_CMX = $(PARSER_DEP:%=%.cmx)
......@@ -25,12 +29,12 @@ include ../config/Makefile
#executables
grew.byte: $(FILES_CMO) parser/parser_global.cmo parser_byte parser/grew_parser.cmo grew.ml
grew.byte: parser/parser_global.cmo parser_byte parser/grew_parser.cmo $(FILES_CMO) grew.ml
$(OCAMLC) $(BYTE_FLAGS) -o grew.byte $(XML_LIGHT_BYTE) $(ANSITERMINAL_BYTE) $(LOG_BYTE) \
$(FILES_CMO) -I parser $(PARSER_CMO) \
grew.ml
grew: $(FILES_CMX) parser/parser_global.cmx parser_opt parser/grew_parser.cmx grew.ml
grew: parser/parser_global.cmx parser_opt parser/grew_parser.cmx $(FILES_CMX) grew.ml
$(OCAMLOPT) $(OPT_FLAGS) -o grew str.cmxa unix.cmxa $(XML_LIGHT_OPT) $(ANSITERMINAL_OPT) $(LOG_OPT) \
$(FILES_CMX) -I parser $(PARSER_CMX) \
grew.ml
......@@ -45,6 +49,7 @@ test: parser/parser_global.cmx parser_opt parser/grew_parser.cmx $(FILES_CMX) $(
$(FILES_CMX) -I parser $(PARSER_CMX) \
test.ml
#parser
parser_opt:
@make -C parser
......@@ -71,19 +76,19 @@ libgrew.mli : grew_types.mli libgrew_.mli
libgrew.cma : $(FILES_CMO) parser_byte libgrew.mli libgrew.ml
ifeq (@DEP2PICT@,no)
$(OCAMLC) -c -pp 'camlp4o pa_macro.cmo' $(BYTE_FLAGS) $(FILES_CMO) $(XML_LIGHT_BYTE) str.cma -I parser $(PARSER_CMO) libgrew.mli
$(OCAMLC) -a -o libgrew.cma $(BYTE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -linkall $(FILES_CMO) -I parser $(PARSER_CMO) libgrew.ml
$(OCAMLC) -a -o libgrew.cma $(BYTE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -linkall -I parser $(PRE_FILES_CMO) $(PARSER_CMO) $(POST_FILES_CMO) libgrew.ml
else
$(OCAMLC) -c -pp 'camlp4o pa_macro.cmo -DDEP2PICT' $(BYTE_FLAGS) $(FILES_CMO) $(XML_LIGHT_BYTE) str.cma -I parser $(PARSER_CMO) libgrew.mli
$(OCAMLC) -a -o libgrew.cma $(BYTE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" -DDEP2PICT' -linkall $(FILES_CMO) -I parser $(PARSER_CMO) libgrew.ml
$(OCAMLC) -a -o libgrew.cma $(BYTE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" -DDEP2PICT' -linkall -I parser $(PRE_FILES_CMO) $(PARSER_CMO) $(POST_FILES_CMO) libgrew.ml
endif
libgrew.cmxa : $(FILES_CMX) parser_opt libgrew.mli libgrew.ml
ifeq (@DEP2PICT@,no)
$(OCAMLOPT) -c -pp 'camlp4o pa_macro.cmo' $(OPT_FLAGS) $(FILES_CMX) $(XML_LIGHT_OPT) str.cmxa -I parser $(PARSER_CMX) libgrew.mli
$(OCAMLOPT) -a -o libgrew.cmxa $(OPT_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -linkall $(FILES_CMX) -I parser $(PARSER_CMX) libgrew.ml
$(OCAMLOPT) -a -o libgrew.cmxa $(OPT_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -linkall -I parser $(PRE_FILES_CMX) $(PARSER_CMX) $(POST_FILES_CMX) libgrew.ml
else
$(OCAMLOPT) -c -pp 'camlp4o pa_macro.cmo -DDEP2PICT' $(FILES_CMX) $(XML_LIGHT_OPT) str.cmxa -I parser $(PARSER_CMX) libgrew.mli
$(OCAMLOPT) -a -o libgrew.cmxa -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" -DDEP2PICT' -linkall $(FILES_CMX) -I parser $(PARSER_CMX) libgrew.ml
$(OCAMLOPT) -a -o libgrew.cmxa -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" -DDEP2PICT' -linkall -I parser $(PRE_FILES_CMX) $(PARSER_CMX) $(POST_FILES_CMX) libgrew.ml
endif
DEPENDS_DIR= -I parser
......@@ -290,10 +295,10 @@ GREW_GRS_CMX = $(GREW_GRS_DEP:%=%.cmx)
grew_grs.cmi: $(GREW_GRS_CMI) grew_grs.mli
$(OCAMLC) -c grew_grs.mli
grew_grs.cmo: $(GREW_GRS_CMO) grew_grs.cmi grew_grs.ml
grew_grs.cmo: parser_byte $(GREW_GRS_CMO) grew_grs.cmi grew_grs.ml
$(OCAMLC) $(BYTE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -c $(DEPENDS_DIR) grew_grs.ml
grew_grs.cmx: $(GREW_GRS_CMX) grew_grs.cmi grew_grs.ml
grew_grs.cmx: parser_opt $(GREW_GRS_CMX) grew_grs.cmi grew_grs.ml
$(OCAMLOPT) $(OPT_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -c $(DEPENDS_DIR) grew_grs.ml
################################################################################
......
......@@ -247,4 +247,6 @@ module Ast = struct
nodes: node list;
edges: edge list;
}
let empty_grs = { domain = []; labels = []; modules = []; sequences= [] }
end (* module Ast *)
......@@ -169,4 +169,6 @@ module Ast : sig
nodes: node list;
edges: edge list;
}
val empty_grs: grs
end (* module Ast *)
......@@ -8,6 +8,7 @@ open Grew_edge
open Grew_command
open Grew_graph
open Grew_rule
open Grew_parser
(* ==================================================================================================== *)
module Rewrite_history = struct
......@@ -175,13 +176,17 @@ module Grs = struct
labels: Label.t list; (* the list of global edge labels *)
modules: Modul.t list; (* the ordered list of modules used from rewriting *)
sequences: Sequence.t list;
filename: string;
ast: Ast.grs;
}
let get_modules t = t.modules
let get_ast t = t.ast
let get_filename t = t.filename
let sequence_names t = List.map (fun s -> s.Sequence.name) t.sequences
let empty = {labels=[]; modules=[]; sequences=[];}
let empty = {labels=[]; modules=[]; sequences=[]; ast=Ast.empty_grs; filename=""; }
let check t =
(* check for duplicate modules *)
......@@ -200,14 +205,15 @@ module Grs = struct
| s::tail -> loop (s.Sequence.name :: already_defined) tail in
loop [] t.sequences
let build ast_grs =
Label.init ast_grs.Ast.labels;
Domain.init ast_grs.Ast.domain;
let modules = List.map Modul.build ast_grs.Ast.modules in
let build filename =
let ast = Grew_parser.grs_of_file filename in
Label.init ast.Ast.labels;
Domain.init ast.Ast.domain;
let modules = List.map Modul.build ast.Ast.modules in
let grs = {
labels = List.map (fun (l,_) -> Label.from_string l) ast_grs.Ast.labels;
modules = modules;
sequences = List.map (Sequence.build modules) ast_grs.Ast.sequences;
labels = List.map (fun (l,_) -> Label.from_string l) ast.Ast.labels;
sequences = List.map (Sequence.build modules) ast.Ast.sequences;
modules; ast; filename;
} in
check grs; grs
......
......@@ -62,9 +62,14 @@ module Grs: sig
val get_modules: t -> Modul.t list
val get_ast: t -> Ast.grs
val get_filename: t -> string
val sequence_names: t -> string list
val build: Ast.grs -> t
(** [build filename] returns the GRS defined in the file [filename] *)
val build: string -> t
val rewrite: t -> string -> Instance.t -> Rewrite_history.t
......
......@@ -377,7 +377,9 @@ module Html_doc = struct
Buffer.contents buff
(* dep is a flag which is true iff dep file are shown in doc (iff dep2pict is available) *)
let build ~dep file output_dir ast =
let build ~dep output_dir grs =
let filename = Grs.get_filename grs in
let ast = Grs.get_ast grs in
ignore(Sys.command ("rm -rf "^output_dir));
ignore(Sys.command ("mkdir "^output_dir));
ignore(Sys.command ("cp "^DATA_DIR^"/style.css "^output_dir));
......@@ -390,14 +392,14 @@ module Html_doc = struct
let buff = Buffer.create 32 in
let wnl fmt = Printf.ksprintf (fun x -> Printf.bprintf buff "%s\n" x) fmt in
let title = sprintf "Grew -- Graph Rewriting System: %s" (Filename.basename file) in
let title = sprintf "Grew -- Graph Rewriting System: %s" (Filename.basename filename) in
html_header ~title buff;
wnl " <body>";
wnl "<a href=\"../sentences.html\">Sentences</a> -- <a href=\"../index.html\">Rewriting stats</a> -- GRS documentation";
wnl "<h1>Graph Rewriting System: %s</h1>" (Filename.basename file);
wnl "<center><b>full path</b>: %s</center>" file;
wnl "<h1>Graph Rewriting System: %s</h1>" (Filename.basename filename);
wnl "<center><b>full path</b>: %s</center>" filename;
wnl "<a href=domain.html>Domain</a><br/>";
wnl "<a href=modules.html>Index of modules</a><br/>";
......@@ -471,7 +473,9 @@ module Html_doc = struct
close_out page_out_ch;
done;
done
end
end (* module Html_doc *)
(* ==================================================================================================== *)
module Html_rh = struct
let build ?filter ?main_feat ?(dot=false) ?(init_graph=true) ?(out_gr=false) ?header ?graph_file prefix t =
......
open Grew_ast
open Grew_rule
open Grew_grs
module Html_doc : sig
val build: dep:bool -> string -> string -> Ast.grs -> unit
val build: dep:bool -> string -> Grs.t -> unit
end
module Html_sentences : sig
......
......@@ -55,10 +55,10 @@ let num_sol rh =
IFDEF DEP2PICT THEN
let build_doc file dir grs_ast grs =
handle ~name:"build_doc [with Dep2pict]" ~file
let build_html_doc dir grs =
handle ~name:"build_doc [with Dep2pict]"
(fun () ->
Html_doc.build ~dep:true file dir grs_ast;
Html_doc.build ~dep:true dir grs;
(* draw pattern graphs for all rules and all filters *)
let fct module_ rule_ =
......@@ -69,22 +69,16 @@ let build_doc file dir grs_ast grs =
Grs.filter_iter fct grs
) ()
ELSE
let build_doc file dir grs_ast grs =
handle ~name:"build_doc [without Dep2pict]" (fun () -> Html_doc.build ~dep:false file dir grs_ast) ()
let build_html_doc dir grs =
handle ~name:"build_doc [without Dep2pict]" (fun () -> Html_doc.build ~dep:false grs_ dir) ()
END
let load_grs ?doc_output_dir file =
let load_grs file =
handle ~name:"load_grs" ~file
(fun () ->
if not (Sys.file_exists file)
then raise (File_dont_exists file)
else
let grs_ast = Grew_parser.grs_of_file file in
let grs = Grs.build grs_ast in
(match doc_output_dir with
| None -> ()
| Some dir -> build_doc file dir grs_ast grs);
grs
else Grs.build file
) ()
let to_sentence ?main_feat gr =
......
......@@ -43,7 +43,10 @@ val empty_grs: Grs.t
@raise Parsing_err if libgrew can't parse the file
@raise File_dont_exists if the file doesn't exists
*)
val load_grs : ?doc_output_dir:string -> string -> Grs.t
val load_grs: string -> Grs.t
(** [build_html_doc directory grs ] *)
val build_html_doc: string -> Grs.t -> unit
(** give the list of sequence names defined in a GRS
@return a string list
......
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