Commit 28d60fa6 authored by bguillaum's avatar bguillaum

html doc and speed up compilation

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@7035 7838e531-6607-4d57-9587-6c381814729c
parent 41b36b1d
......@@ -26,22 +26,22 @@ include ../config/Makefile
#executables
grew.byte: $(FILES_CMO) parser/parser_global.cmo parser_byte parser/grew_parser.cmo grew.ml
ocamlc $(BYTE_FLAGS) -o grew.byte $(ANSITERMINAL_BYTE) $(LOG_BYTE) \
ocamlc.opt $(BYTE_FLAGS) -o grew.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
ocamlopt $(OPT_FLAGS) -o grew str.cmxa unix.cmxa $(ANSITERMINAL_OPT) $(LOG_OPT) \
ocamlopt.opt $(OPT_FLAGS) -o grew str.cmxa unix.cmxa $(ANSITERMINAL_OPT) $(LOG_OPT) \
$(FILES_CMX) -I parser $(PARSER_CMX) \
grew.ml
test.byte: parser/parser_global.cmo parser_byte parser/grew_parser.cmo $(FILES_CMO) $(FILES_CMI) test.ml
ocamlc $(BYTE_FLAGS) -o test.byte $(ANSITERMINAL_BYTE) $(LOG_BYTE) \
ocamlc.opt $(BYTE_FLAGS) -o test.byte $(ANSITERMINAL_BYTE) $(LOG_BYTE) \
$(FILES_CMO) -I parser $(PARSER_CMO) \
test.ml
test: parser/parser_global.cmx parser_opt parser/grew_parser.cmx $(FILES_CMX) $(FILES_CMI) test.ml
ocamlopt $(OPT_FLAGS) -o test str.cmxa unix.cmxa $(ANSITERMINAL_OPT) $(LOG_OPT) \
ocamlopt.opt $(OPT_FLAGS) -o test str.cmxa unix.cmxa $(ANSITERMINAL_OPT) $(LOG_OPT) \
$(FILES_CMX) -I parser $(PARSER_CMX) \
test.ml
......@@ -70,20 +70,20 @@ 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' $(BYPE_FLAGS) $(FILES_CMO) str.cma -I parser $(PARSER_CMO) libgrew.mli
ocamlc -a -o libgrew.cma $(BYPE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -linkall $(FILES_CMO) -I parser $(PARSER_CMO) libgrew.ml
ocamlc.opt -c -pp 'camlp4o pa_macro.cmo' $(BYPE_FLAGS) $(FILES_CMO) str.cma -I parser $(PARSER_CMO) libgrew.mli
ocamlc.opt -a -o libgrew.cma $(BYPE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -linkall $(FILES_CMO) -I parser $(PARSER_CMO) libgrew.ml
else
ocamlc -c -pp 'camlp4o pa_macro.cmo -DDEP2PICT' $(BYPE_FLAGS) $(FILES_CMO) str.cma -I parser $(PARSER_CMO) libgrew.mli
ocamlc -a -o libgrew.cma $(BYPE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" -DDEP2PICT' -linkall $(FILES_CMO) -I parser $(PARSER_CMO) libgrew.ml
ocamlc.opt -c -pp 'camlp4o pa_macro.cmo -DDEP2PICT' $(BYPE_FLAGS) $(FILES_CMO) str.cma -I parser $(PARSER_CMO) libgrew.mli
ocamlc.opt -a -o libgrew.cma $(BYPE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" -DDEP2PICT' -linkall $(FILES_CMO) -I parser $(PARSER_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) 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.opt -c -pp 'camlp4o pa_macro.cmo' $(OPT_FLAGS) $(FILES_CMX) str.cmxa -I parser $(PARSER_CMX) libgrew.mli
ocamlopt.opt -a -o libgrew.cmxa $(OPT_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -linkall $(FILES_CMX) -I parser $(PARSER_CMX) libgrew.ml
else
ocamlopt -c -pp 'camlp4o pa_macro.cmo -DDEP2PICT' $(FILES_CMX) 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.opt -c -pp 'camlp4o pa_macro.cmo -DDEP2PICT' $(FILES_CMX) str.cmxa -I parser $(PARSER_CMX) libgrew.mli
ocamlopt.opt -a -o libgrew.cmxa -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" -DDEP2PICT' -linkall $(FILES_CMX) -I parser $(PARSER_CMX) libgrew.ml
endif
DEPENDS_DIR= -I parser
......@@ -95,13 +95,13 @@ GREW_CORE_CMO = $(GREW_CORE_DEP:%=%.cmo)
GREW_CORE_CMX = $(GREW_CORE_DEP:%=%.cmx)
grew_core.cmi: $(GREW_CORE_CMI) grew_core.mli
ocamlc -c grew_core.mli
ocamlc.opt -c grew_core.mli
grew_core.cmo: $(GREW_CORE_CMO) parser_byte grew_core.cmi grew_core.ml
ocamlc $(BYTE_FLAGS) -c $(DEPENDS_DIR) $(GREW_CORE_CMO) grew_core.ml
ocamlc.opt $(BYTE_FLAGS) -c $(DEPENDS_DIR) $(GREW_CORE_CMO) grew_core.ml
grew_core.cmx: $(GREW_CORE_CMX) parser_opt grew_core.cmi grew_core.ml
ocamlopt $(OPT_FLAGS) -c $(DEPENDS_DIR) $(GREW_CORE_CMX) grew_core.ml
ocamlopt.opt $(OPT_FLAGS) -c $(DEPENDS_DIR) $(GREW_CORE_CMX) grew_core.ml
################################################################################
###### grew_utils.ml ##############################################################
......@@ -111,13 +111,13 @@ GREW_UTILS_CMO = $(GREW_UTILS_DEP:%=%.cmo)
GREW_UTILS_CMX = $(GREW_UTILS_DEP:%=%.cmx)
grew_utils.cmi: $(GREW_UTILS_CMI) grew_utils.mli
ocamlc -c grew_utils.mli
ocamlc.opt -c grew_utils.mli
grew_utils.cmo: $(GREW_UTILS_CMO) grew_utils.cmi grew_utils.ml
ocamlc $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_utils.ml
ocamlc.opt $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_utils.ml
grew_utils.cmx: $(GREW_UTILS_CMX) grew_utils.cmi grew_utils.ml
ocamlopt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_utils.ml
ocamlopt.opt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_utils.ml
################################################################################
......@@ -128,13 +128,13 @@ GREW_AST_CMO = $(GREW_AST_DEP:%=%.cmo)
GREW_AST_CMX = $(GREW_AST_DEP:%=%.cmx)
grew_ast.cmi: $(GREW_AST_CMI) grew_ast.mli
ocamlc -c grew_ast.mli
ocamlc.opt -c grew_ast.mli
grew_ast.cmo: $(GREW_AST_CMO) grew_ast.cmi grew_ast.ml
ocamlc $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_ast.ml
ocamlc.opt $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_ast.ml
grew_ast.cmx: $(GREW_AST_CMX) grew_ast.cmi grew_ast.ml
ocamlopt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_ast.ml
ocamlopt.opt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_ast.ml
################################################################################
......@@ -145,13 +145,13 @@ GREW_HTML_CMO = $(GREW_HTML_DEP:%=%.cmo)
GREW_HTML_CMX = $(GREW_HTML_DEP:%=%.cmx)
grew_html.cmi: $(GREW_HTML_CMI) grew_html.mli
ocamlc -c grew_html.mli
ocamlc.opt -c grew_html.mli
grew_html.cmo: $(GREW_HTML_CMO) grew_html.cmi grew_html.ml
ocamlc $(BYTE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -c $(DEPENDS_DIR) grew_html.ml
ocamlc.opt $(BYTE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -c $(DEPENDS_DIR) grew_html.ml
grew_html.cmx: $(GREW_HTML_CMX) grew_html.cmi grew_html.ml
ocamlopt $(OPT_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -c $(DEPENDS_DIR) grew_html.ml
ocamlopt.opt $(OPT_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -c $(DEPENDS_DIR) grew_html.ml
################################################################################
###### grew_fs.ml ##############################################################
......@@ -161,13 +161,13 @@ GREW_FS_CMO = $(GREW_FS_DEP:%=%.cmo)
GREW_FS_CMX = $(GREW_FS_DEP:%=%.cmx)
grew_fs.cmi: $(GREW_FS_CMI) grew_fs.mli
ocamlc -c grew_fs.mli
ocamlc.opt -c grew_fs.mli
grew_fs.cmo: $(GREW_FS_CMO) grew_fs.cmi grew_fs.ml
ocamlc $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_fs.ml
ocamlc.opt $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_fs.ml
grew_fs.cmx: $(GREW_FS_CMX) grew_fs.cmi grew_fs.ml
ocamlopt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_fs.ml
ocamlopt.opt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_fs.ml
################################################################################
......@@ -178,13 +178,13 @@ GREW_EDGE_CMO = $(GREW_EDGE_DEP:%=%.cmo)
GREW_EDGE_CMX = $(GREW_EDGE_DEP:%=%.cmx)
grew_edge.cmi: $(GREW_EDGE_CMI) grew_edge.mli
ocamlc -c grew_edge.mli
ocamlc.opt -c grew_edge.mli
grew_edge.cmo: $(GREW_EDGE_CMO) grew_edge.cmi grew_edge.ml
ocamlc $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_edge.ml
ocamlc.opt $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_edge.ml
grew_edge.cmx: $(GREW_EDGE_CMX) grew_edge.cmi grew_edge.ml
ocamlopt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_edge.ml
ocamlopt.opt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_edge.ml
################################################################################
......@@ -195,13 +195,13 @@ GREW_NODE_CMO = $(GREW_NODE_DEP:%=%.cmo)
GREW_NODE_CMX = $(GREW_NODE_DEP:%=%.cmx)
grew_node.cmi: $(GREW_NODE_CMI) grew_node.mli
ocamlc -c grew_node.mli
ocamlc.opt -c grew_node.mli
grew_node.cmo: $(GREW_NODE_CMO) grew_node.cmi grew_node.ml
ocamlc $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_node.ml
ocamlc.opt $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_node.ml
grew_node.cmx: $(GREW_NODE_CMX) grew_node.cmi grew_node.ml
ocamlopt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_node.ml
ocamlopt.opt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_node.ml
################################################################################
......@@ -212,13 +212,13 @@ GREW_GRAPH_CMO = $(GREW_GRAPH_DEP:%=%.cmo)
GREW_GRAPH_CMX = $(GREW_GRAPH_DEP:%=%.cmx)
grew_graph.cmi: $(GREW_GRAPH_CMI) grew_graph.mli
ocamlc -c grew_graph.mli
ocamlc.opt -c grew_graph.mli
grew_graph.cmo: $(GREW_GRAPH_CMO) grew_graph.cmi grew_graph.ml
ocamlc $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_graph.ml
ocamlc.opt $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_graph.ml
grew_graph.cmx: $(GREW_GRAPH_CMX) grew_graph.cmi grew_graph.ml
ocamlopt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_graph.ml
ocamlopt.opt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_graph.ml
################################################################################
......@@ -229,13 +229,13 @@ GREW_TYPES_CMO = $(GREW_TYPES_DEP:%=%.cmo)
GREW_TYPES_CMX = $(GREW_TYPES_DEP:%=%.cmx)
grew_types.cmi: $(GREW_TYPES_CMI) grew_types.mli
ocamlc -c grew_types.mli
ocamlc.opt -c grew_types.mli
grew_types.cmo: $(GREW_TYPES_CMO) grew_types.cmi grew_types.ml
ocamlc $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_types.ml
ocamlc.opt $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_types.ml
grew_types.cmx: $(GREW_TYPES_CMX) grew_types.cmi grew_types.ml
ocamlopt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_types.ml
ocamlopt.opt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_types.ml
################################################################################
......@@ -246,13 +246,13 @@ GREW_COMMAND_CMO = $(GREW_COMMAND_DEP:%=%.cmo)
GREW_COMMAND_CMX = $(GREW_COMMAND_DEP:%=%.cmx)
grew_command.cmi: $(GREW_COMMAND_CMI) grew_command.mli
ocamlc -c grew_command.mli
ocamlc.opt -c grew_command.mli
grew_command.cmo: $(GREW_COMMAND_CMO) grew_command.cmi grew_command.ml
ocamlc $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_command.ml
ocamlc.opt $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_command.ml
grew_command.cmx: $(GREW_COMMAND_CMX) grew_command.cmi grew_command.ml
ocamlopt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_command.ml
ocamlopt.opt $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_command.ml
################################################################################
......@@ -264,23 +264,23 @@ GREW_RULE_CMX = $(GREW_RULE_DEP:%=%.cmx)
grew_rule.cmi: $(GREW_RULE_CMI) grew_rule.mli
ifeq (@DEP2PICT@,no)
ocamlc -c -pp 'camlp4o pa_macro.cmo' grew_rule.mli
ocamlc.opt -c -pp 'camlp4o pa_macro.cmo' grew_rule.mli
else
ocamlc -c -pp 'camlp4o pa_macro.cmo -DDEP2PICT' grew_rule.mli
ocamlc.opt -c -pp 'camlp4o pa_macro.cmo -DDEP2PICT' grew_rule.mli
endif
grew_rule.cmo: $(GREW_RULE_CMO) grew_rule.cmi grew_rule.ml
ifeq (@DEP2PICT@,no)
ocamlc -pp 'camlp4o pa_macro.cmo' $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_rule.ml
ocamlc.opt -pp 'camlp4o pa_macro.cmo' $(BYTE_FLAGS) -c $(DEPENDS_DIR) grew_rule.ml
else
ocamlc -pp 'camlp4o pa_macro.cmo -DDEP2PICT' $(BYTE_FLAGS) -c $(DEPENDS_DIR) $(DEP2PICT_BYTE) grew_rule.ml
ocamlc.opt -pp 'camlp4o pa_macro.cmo -DDEP2PICT' $(BYTE_FLAGS) -c $(DEPENDS_DIR) $(DEP2PICT_BYTE) grew_rule.ml
endif
grew_rule.cmx: $(GREW_RULE_CMX) grew_rule.cmi grew_rule.ml
ifeq (@DEP2PICT@,no)
ocamlopt -pp 'camlp4o pa_macro.cmo' $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_rule.ml
ocamlopt.opt -pp 'camlp4o pa_macro.cmo' $(OPT_FLAGS) -c $(DEPENDS_DIR) grew_rule.ml
else
ocamlopt -pp 'camlp4o pa_macro.cmo -DDEP2PICT' $(OPT_FLAGS) -c $(DEPENDS_DIR) $(DEP2PICT_OPT) grew_rule.ml
ocamlopt.opt -pp 'camlp4o pa_macro.cmo -DDEP2PICT' $(OPT_FLAGS) -c $(DEPENDS_DIR) $(DEP2PICT_OPT) grew_rule.ml
endif
################################################################################
......@@ -293,23 +293,23 @@ GREW_GRS_CMX = $(GREW_GRS_DEP:%=%.cmx)
grew_grs.cmi: $(GREW_GRS_CMI) grew_grs.mli
ifeq (@DEP2PICT@,no)
ocamlc -c -pp 'camlp4o pa_macro.cmo' grew_grs.mli
ocamlc.opt -c -pp 'camlp4o pa_macro.cmo' grew_grs.mli
else
ocamlc -c -pp 'camlp4o pa_macro.cmo -DDEP2PICT' grew_grs.mli
ocamlc.opt -c -pp 'camlp4o pa_macro.cmo -DDEP2PICT' grew_grs.mli
endif
grew_grs.cmo: $(GREW_GRS_CMO) grew_grs.cmi grew_grs.ml
ifeq (@DEP2PICT@,no)
ocamlc $(BYTE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -c $(DEPENDS_DIR) grew_grs.ml
ocamlc.opt $(BYTE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -c $(DEPENDS_DIR) grew_grs.ml
else
ocamlc $(BYTE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" -DDEP2PICT' -c $(DEPENDS_DIR) grew_grs.ml
ocamlc.opt $(BYTE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" -DDEP2PICT' -c $(DEPENDS_DIR) grew_grs.ml
endif
grew_grs.cmx: $(GREW_GRS_CMX) grew_grs.cmi grew_grs.ml
ifeq (@DEP2PICT@,no)
ocamlopt $(OPT_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -c $(DEPENDS_DIR) grew_grs.ml
ocamlopt.opt $(OPT_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -c $(DEPENDS_DIR) grew_grs.ml
else
ocamlopt $(OPT_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" -DDEP2PICT' -c $(DEPENDS_DIR) grew_grs.ml
ocamlopt.opt $(OPT_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" -DDEP2PICT' -c $(DEPENDS_DIR) grew_grs.ml
endif
################################################################################
......
......@@ -43,9 +43,9 @@ module Ast = struct
type u_const =
| Start of Id.name * string list (* (source, labels) *)
| No_out of Id.name
| Cst_out of Id.name
| End of Id.name * string list (* (target, labels) *)
| No_in of Id.name
| Cst_in of Id.name
| Feature_eq of qfn * qfn
type const = u_const * Loc.t
......
......@@ -43,9 +43,9 @@ module Ast : sig
type u_const =
| Start of Id.name * string list (* (source, labels) *)
| No_out of Id.name
| Cst_out of Id.name
| End of Id.name * string list (* (target, labels) *)
| No_in of Id.name
| Cst_in of Id.name
| Feature_eq of qfn * qfn
type const = u_const * Loc.t
......@@ -76,12 +76,13 @@ module Ast : sig
| Update_feat of qfn * concat_item list
type command = u_command * Loc.t
type rule = {
rule_id:Id.name;
pos_pattern: pattern;
neg_patterns: pattern list;
commands: command list;
param: (string*string list) option;
param: (string*string list) option; (* (file, vars) *)
rule_doc:string list;
rule_loc: Loc.t;
}
......
......@@ -94,39 +94,6 @@ module P_graph = struct
) map_without_edges full_edge_list in
(map, table, [](* List.map (build_filter table) constraints *))
let to_dep t =
let buff = Buffer.create 32 in
bprintf buff "[GRAPH] { scale = 200; }\n";
bprintf buff "[WORDS] {\n";
Pid_map.iter
(fun id node ->
bprintf buff " N_%d { word=\"%s\"; subword=\"%s\"}\n"
id
(P_node.get_name node)
(P_fs.to_dep (P_node.get_fs node))
) t;
bprintf buff "}\n";
bprintf buff "[EDGES] {\n";
Pid_map.iter
(fun id_src node ->
Massoc.iter
(fun id_tar edge ->
bprintf buff " N_%d -> N_%d { label=\"%s\"}\n"
id_src id_tar
(P_edge.to_string edge)
)
(P_node.get_next node)
) t;
bprintf buff "}\n";
Buffer.contents buff
(* a type for extension of graph: a former graph exists:
......
......@@ -24,8 +24,6 @@ module P_graph: sig
old_map: P_node.t Pid_map.t; (* a partial map for new constraints on old nodes "Old [...]" *)
}
val to_dep: t -> string
val build:
?pat_vars: string list ->
?locals: Label.decl array ->
......
......@@ -320,10 +320,13 @@ module Grs = struct
let rule_iter fct grs =
List.iter
(fun modul ->
List.iter
(fun rule ->
fct modul.Modul.name rule
) modul.Modul.rules
List.iter (fun rule -> fct modul.Modul.name rule) modul.Modul.rules
) grs.modules
let filter_iter fct grs =
List.iter
(fun modul ->
List.iter (fun filter -> fct modul.Modul.name filter) modul.Modul.filters
) grs.modules
end
......
......@@ -40,6 +40,7 @@ module Grs: sig
val build_rew_display: t -> string -> Instance.t -> Grew_types.rew_display
val rule_iter: (string -> Rule.t -> unit) -> t -> unit
val filter_iter: (string -> Rule.t -> unit) -> t -> unit
end
......
......@@ -59,9 +59,9 @@ module Html = struct
bprintf buff " ";
(match u_const with
| Ast.Start (id,labels) -> bprintf buff "%s -[%s]-> *" id (List_.to_string (fun x->x) "|" labels)
| Ast.No_out id -> bprintf buff "%s -> *" id
| Ast.Cst_out id -> bprintf buff "%s -> *" id
| Ast.End (id,labels) -> bprintf buff "* -[%s]-> %s" (List_.to_string (fun x->x) "|" labels) id
| Ast.No_in id -> bprintf buff "* -> %s" id
| Ast.Cst_in id -> bprintf buff "* -> %s" id
| Ast.Feature_eq (qfn_l, qfn_r) -> bprintf buff "%s = %s" (string_of_qfn qfn_l) (string_of_qfn qfn_r));
bprintf buff "\n"
......@@ -84,7 +84,15 @@ module Html = struct
let buff = Buffer.create 32 in
List.iter
(fun rule ->
bprintf buff "<font color=\"purple\">rule</font> %s <b>{</b>\n" rule.Ast.rule_id;
(match (rule.Ast.commands, rule.Ast.param) with
| ([], None) ->
bprintf buff "<font color=\"purple\">filter</font> %s <b>{</b>\n" rule.Ast.rule_id
| (_,None) ->
bprintf buff "<font color=\"purple\">rule</font> %s <b>{</b>\n" rule.Ast.rule_id
| (_,Some (file, vars)) ->
let param = sprintf "(feature %s; file \"%s\")" (String.concat ", " vars) file in
bprintf buff "<font color=\"purple\">lex_rule</font> %s %s <b>{</b>\n" rule.Ast.rule_id param
);
(* the match part *)
buff_html_pos_pattern buff rule.Ast.pos_pattern;
......@@ -93,9 +101,12 @@ module Html = struct
List.iter (buff_html_neg_pattern buff) rule.Ast.neg_patterns;
(* the commands part *)
bprintf buff " <font color=\"purple\">commands</font> <b>{</b>\n";
List.iter (buff_html_command buff) rule.Ast.commands;
bprintf buff " <b>}</b>\n";
(match rule.Ast.commands with
| [] -> () (* filter *)
| list ->
bprintf buff " <font color=\"purple\">commands</font> <b>{</b>\n";
List.iter (buff_html_command buff) list;
bprintf buff " <b>}</b>\n");
bprintf buff "<b>}</b>\n";
) rules;
......@@ -191,6 +202,22 @@ module Html = struct
w "<IMG src=\"%s\">" dep_pattern_file;
wnl "</pre>";
(match rule_.Ast.param with
| None -> ()
| Some (file, args) ->
let filename = Filename.concat module_.Ast.mod_dir file in
wnl "<h6>Lexical parameters</h6>";
wnl "<b>File:</b> %s</br>" file;
let lines =
try File.read filename
with Sys_error msg -> wnl "<font color=\"red\">Error: %s</font>" msg; [] in
wnl " <table border=\"1\">";
wnl " <tr>%s</tr>" (List_.to_string (fun x -> sprintf "<th bgcolor=\"#cccccc\">%s</th>" x) "" args);
List.iter
(fun l -> wnl "<tr>%s</tr>"
(List_.to_string (fun x -> sprintf "<td>%s</td>" x) "" (Str.split (Str.regexp "#+") l))
) lines);
wnl " </table>";
wnl " </body>";
wnl "</html>";
Buffer.contents buff
......
......@@ -77,6 +77,7 @@ module P_node = struct
name: Id.name;
fs: P_fs.t;
next: P_edge.t Massoc.t;
loc: Loc.t option;
}
let get_name t = t.name
......@@ -85,7 +86,7 @@ module P_node = struct
let unif_fs fs t = { t with fs = P_fs.unif fs t.fs }
let empty = { fs = P_fs.empty; next = Massoc.empty; name = "" }
let empty = { fs = P_fs.empty; next = Massoc.empty; name = ""; loc=None }
let build ?pat_vars (ast_node, loc) =
(ast_node.Ast.node_id,
......@@ -93,6 +94,7 @@ module P_node = struct
name = ast_node.Ast.node_id;
fs = P_fs.build ?pat_vars ast_node.Ast.fs;
next = Massoc.empty;
loc = Some loc;
} )
let add_edge p_edge pid_tar t =
......@@ -102,6 +104,7 @@ module P_node = struct
let match_ ?param p_node g_node = P_fs.match_ ?param p_node.fs (G_node.get_fs g_node)
let compare_pos t1 t2 = Pervasives.compare t1.loc t2.loc
end
(* ================================================================================ *)
......
......@@ -56,5 +56,6 @@ module P_node: sig
val match_: ?param: Lex_par.t -> t -> G_node.t -> Lex_par.t option
val compare_pos: t -> t -> int
end
(* ================================================================================ *)
......@@ -32,7 +32,6 @@ module Instance = struct
{ empty with graph = graph }
let of_conll ?loc lines =
(match loc with None -> "None" | Some (f,l) -> Printf.sprintf "(%s,%d)" f l);
{ empty with graph = G_graph.of_conll ?loc lines }
let rev_steps t =
......@@ -57,9 +56,6 @@ end (* module Instance *)
module Instance_set = Set.Make (Instance)
(* ================================================================================ *)
module Rule = struct
(* the [pid] type is used for pattern identifier *)
type pid = Pid.t
......@@ -70,17 +66,17 @@ module Rule = struct
(* the rewriting depth is bounded to stop rewriting when the system is not terminating *)
let max_depth = ref 500
type const =
| No_out of pid * P_edge.t
| No_in of pid * P_edge.t
type const =
| Cst_out of pid * P_edge.t
| Cst_in of pid * P_edge.t
| Feature_eq of pid * string * pid * string
| Filter of pid * P_fs.t (* used when a without impose a fs on a node defined by the match pattern *)
let build_constraint ?locals table = function
| (Ast.Start (node_name, labels), loc) -> No_out (Id.build ~loc node_name table, P_edge.make ?locals labels)
| (Ast.No_out node_name, loc) -> No_out (Id.build ~loc node_name table, P_edge.all)
| (Ast.End (node_name, labels),loc) -> No_in (Id.build ~loc node_name table, P_edge.make ?locals labels)
| (Ast.No_in node_name, loc) -> No_in (Id.build ~loc node_name table, P_edge.all)
| (Ast.Start (node_name, labels), loc) -> Cst_out (Id.build ~loc node_name table, P_edge.make ?locals labels)
| (Ast.Cst_out node_name, loc) -> Cst_out (Id.build ~loc node_name table, P_edge.all)
| (Ast.End (node_name, labels),loc) -> Cst_in (Id.build ~loc node_name table, P_edge.make ?locals labels)
| (Ast.Cst_in node_name, loc) -> Cst_in (Id.build ~loc node_name table, P_edge.all)
| (Ast.Feature_eq ((node_name1, feat_name1), (node_name2, feat_name2)), loc) ->
Feature_eq (Id.build ~loc node_name1 table, feat_name1, Id.build ~loc node_name2 table, feat_name2)
......@@ -108,10 +104,10 @@ module Rule = struct
let id_build loc string_id =
match Id.build_opt string_id pos_table with Some i -> i | None -> -1-(Id.build ~loc string_id neg_table) in
match const with
| (Ast.Start (node_name, labels),loc) -> No_out (id_build loc node_name, P_edge.make ?locals labels)
| (Ast.No_out node_name, loc) -> No_out (id_build loc node_name, P_edge.all)
| (Ast.End (node_name, labels),loc) -> No_in (id_build loc node_name, P_edge.make ?locals labels)
| (Ast.No_in node_name, loc) -> No_in (id_build loc node_name, P_edge.all)
| (Ast.Start (node_name, labels),loc) -> Cst_out (id_build loc node_name, P_edge.make ?locals labels)
| (Ast.Cst_out node_name, loc) -> Cst_out (id_build loc node_name, P_edge.all)
| (Ast.End (node_name, labels),loc) -> Cst_in (id_build loc node_name, P_edge.make ?locals labels)
| (Ast.Cst_in node_name, loc) -> Cst_in (id_build loc node_name, P_edge.all)
| (Ast.Feature_eq ((node_name1, feat_name1), (node_name2, feat_name2)), loc) ->
Feature_eq (id_build loc node_name1, feat_name1, id_build loc node_name2, feat_name2)
......@@ -147,7 +143,59 @@ module Rule = struct
let get_loc t = t.loc
let to_dep t = P_graph.to_dep t.pos.graph
let to_dep t =
let buff = Buffer.create 32 in
bprintf buff "[GRAPH] { scale = 200; }\n";
let nodes =
Pid_map.fold
(fun id node acc ->
(node, sprintf " N_%d { word=\"%s\"; subword=\"%s\"}" id (P_node.get_name node) (P_fs.to_dep (P_node.get_fs node)))
:: acc
) t.pos.graph [] in
(* noodes are sorted to appear in the same order in dep picture and in input file *)
let sorted_nodes = List.sort (fun (n1,_) (n2,_) -> P_node.compare_pos n1 n2) nodes in
bprintf buff "[WORDS] {\n";
List.iter
(fun (_, dep_line) -> bprintf buff "%s\n" dep_line
) sorted_nodes;
List_.iteri
(fun i cst ->
match cst with
| Cst_out _ | Cst_in _ -> bprintf buff " C_%d { word=\"*\"}\n" i
| _ -> ()
) t.pos.constraints;
bprintf buff "}\n";
bprintf buff "[EDGES] {\n";
Pid_map.iter
(fun id_src node ->
Massoc.iter
(fun id_tar edge ->
bprintf buff " N_%d -> N_%d { label=\"%s\"}\n"
id_src id_tar
(P_edge.to_string edge)
)
(P_node.get_next node)
) t.pos.graph;
List_.iteri
(fun i cst ->
match cst with
| Cst_out (pid, edge) ->
bprintf buff " N_%d -> C_%d {label = \"%s\"; style=dot; bottom; color=green;}\n"
pid i (P_edge.to_string edge)
| Cst_in (pid, edge) ->
bprintf buff " C_%d -> N_%d {label = \"%s\"; style=dot; bottom; color=green;}\n"
i pid (P_edge.to_string edge)
| _ -> ()
) t.pos.constraints;
bprintf buff "}\n";
Buffer.contents buff
let is_filter t = t.commands = []
......@@ -293,10 +341,10 @@ module Rule = struct
let fullfill graph matching = function
| No_out (pid,edge) ->
| Cst_out (pid,edge) ->
let gid = Pid_map.find pid matching.n_match in
G_graph.edge_out graph gid edge
| No_in (pid,edge) ->
| Cst_in (pid,edge) ->
let gid = Pid_map.find pid matching.n_match in
gid_map_exists (* should be Gid_map.exists with ocaml 3.12 *)
(fun _ node ->
......
......@@ -39,15 +39,17 @@ let load_grs ?doc_output_dir file =
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 ->
| None -> ()
| Some dir ->
Html.proceed dir grs_ast;