Commit 03e4addc authored by bguillaum's avatar bguillaum

code simplification

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@7018 7838e531-6607-4d57-9587-6c381814729c
parent bd968d07
......@@ -192,7 +192,6 @@ config/Makefile \
Makefile \
src/Makefile \
src/parser/Makefile \
src/HTMLer/Makefile \
)
VERSION=`grep "VERSION = .*" config/Makefile.in | sed 's|VERSION = \(.*\)|\1|'`
......
......@@ -1975,7 +1975,7 @@ TRUNK=`pwd`
echo ""
ac_config_files="$ac_config_files config/Makefile Makefile src/Makefile src/parser/Makefile src/HTMLer/Makefile"
ac_config_files="$ac_config_files config/Makefile Makefile src/Makefile src/parser/Makefile"
VERSION=`grep "VERSION = .*" config/Makefile.in | sed 's|VERSION = \(.*\)|\1|'`
......@@ -2739,7 +2739,6 @@ do
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
"src/parser/Makefile") CONFIG_FILES="$CONFIG_FILES src/parser/Makefile" ;;
"src/HTMLer/Makefile") CONFIG_FILES="$CONFIG_FILES src/HTMLer/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
......
all: HTMLer.cmx
byte: HTMLer.cmo
include ../../config/Makefile
HTMLer.cmx: HTMLer.ml ../grew_ast.cmx
ocamlopt -c $(OPT_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -I .. grew_ast.cmx HTMLer.ml
HTMLer.cmo: HTMLer.ml ../grew_ast.cmo
ocamlc -c $(BYTE_FLAGS) -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\"' -I .. grew_ast.cmo HTMLer.ml
FILES_DEP = grew_utils grew_ast grew_fs grew_edge grew_node grew_graph grew_types grew_command grew_rule grew_grs
FILES_DEP = grew_utils grew_ast grew_html grew_fs grew_edge grew_node grew_graph grew_types grew_command grew_rule grew_grs
FILES_ML = $(FILES_DEP:%=%.ml)
FILES_MLI = $(FILES_DEP:%=%.mli)
FILES_CMI = $(FILES_DEP:%=%.cmi)
......@@ -13,10 +13,10 @@ PARSER_CMI = $(PARSER_DEP:%=%.cmi)
PARSER_CMO = $(PARSER_DEP:%=%.cmo)
PARSER_CMX = $(PARSER_DEP:%=%.cmx)
.PHONY: parser HTMLer
.PHONY: parser
all: grew_utils.cmx grew_ast.cmx parser HTMLer grew test
byte: grew_utils.cmo grew_ast.cmo parser.byte HTMLer.byte grew.byte test.byte
all: grew_utils.cmx grew_ast.cmx parser grew test
byte: grew_utils.cmo grew_ast.cmo parser.byte grew.byte test.byte
include ../config/Makefile
......@@ -25,24 +25,24 @@ include ../config/Makefile
#executables
grew.byte: $(FILES_CMO) parser/parser_global.cmo parser_byte parser/grew_parser.cmo HTMLer/HTMLer.cmo grew.ml
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) \
$(FILES_CMO) -I parser $(PARSER_CMO) -I HTMLer HTMLer.cmo \
$(FILES_CMO) -I parser $(PARSER_CMO) \
grew.ml
grew: $(FILES_CMX) parser/parser_global.cmx parser_opt parser/grew_parser.cmx HTMLer/HTMLer.cmx 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) \
$(FILES_CMX) -I parser $(PARSER_CMX) -I HTMLer HTMLer.cmx \
$(FILES_CMX) -I parser $(PARSER_CMX) \
grew.ml
test.byte: parser/parser_global.cmo parser_byte parser/grew_parser.cmo HTMLer/HTMLer.cmo $(FILES_CMO) $(FILES_CMI) test.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) \
$(FILES_CMO) -I parser $(PARSER_CMO) -I HTMLer HTMLer.cmo \
$(FILES_CMO) -I parser $(PARSER_CMO) \
test.ml
test: parser/parser_global.cmx parser_opt parser/grew_parser.cmx HTMLer/HTMLer.cmx $(FILES_CMX) $(FILES_CMI) 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) \
$(FILES_CMX) -I parser $(PARSER_CMX) -I HTMLer HTMLer.cmx \
$(FILES_CMX) -I parser $(PARSER_CMX) \
test.ml
#parser
......@@ -52,13 +52,6 @@ parser_opt:
parser_byte:
@make -C parser byte
#HTMLer
HTMLer_opt:
@make -C HTMLer
HTMLer_byte:
@make -C HTMLer byte
# librairie
libgrew.mli : grew_types.mli libgrew_.mli
......@@ -75,25 +68,25 @@ libgrew.mli : grew_types.mli libgrew_.mli
echo "" >> libgrew.mli
cat libgrew_.mli >> libgrew.mli
libgrew.cma : $(FILES_CMO) parser_byte HTMLer_byte libgrew.mli libgrew.ml
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) -I HTMLer HTMLer.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) -I HTMLer HTMLer.cmo libgrew.ml
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
else
ocamlc -c -pp 'camlp4o pa_macro.cmo -DDEP2PICT' $(FILES_CMO) str.cma -I parser $(PARSER_CMO) -I HTMLer HTMLer.cmo libgrew.mli
ocamlc -a -o libgrew.cma -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" -DDEP2PICT' -linkall $(FILES_CMO) -I parser $(PARSER_CMO) -I HTMLer HTMLer.cmo libgrew.ml
ocamlc -c -pp 'camlp4o pa_macro.cmo -DDEP2PICT' $(FILES_CMO) str.cma -I parser $(PARSER_CMO) libgrew.mli
ocamlc -a -o libgrew.cma -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 HTMLer_opt libgrew.mli libgrew.ml
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) -I HTMLer HTMLer.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) -I HTMLer HTMLer.cmx libgrew.ml
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
else
ocamlopt -c -pp 'camlp4o pa_macro.cmo -DDEP2PICT' $(FILES_CMX) str.cmxa -I parser $(PARSER_CMX) -I HTMLer HTMLer.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) -I HTMLer HTMLer.cmx libgrew.ml
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
endif
DEPENDS_DIR= -I parser -I HTMLer
DEPENDS_DIR= -I parser
###### grew_core.ml ##############################################################
GREW_CORE_DEP = grew_types
......@@ -145,6 +138,22 @@ grew_ast.cmx: $(GREW_AST_CMX) grew_ast.cmi grew_ast.ml
################################################################################
###### grew_html.ml ##############################################################
GREW_HTML_DEP = grew_utils grew_ast
GREW_HTML_CMI = $(GREW_HTML_DEP:%=%.cmi)
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
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
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
################################################################################
###### grew_fs.ml ##############################################################
GREW_FS_DEP = grew_utils grew_ast
GREW_FS_CMI = $(GREW_FS_DEP:%=%.cmi)
......@@ -312,7 +321,6 @@ dep:
clean:
@make -C HTMLer cleanup
@make -C parser clean
rm -rf *.cmi *.cmo *.cmxa *.cma *.cmx *.o *.annot
rm -f grew grew.byte
......@@ -321,7 +329,6 @@ clean:
rm -f libgrew.mli
purge_makefile:
@make -C HTMLer purge
@make -C parser purge
@make purge
......
open Grew_ast
module HTMLer = struct
module Html = struct
let index_text table = "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
......@@ -68,54 +68,7 @@ let rule_page_text previous next rule m ast file = "
<center><h1>Rule <a href=\""^m.Ast.module_id^".html\">"^m.Ast.module_id^"</a>.<div class=\"module_title\">"^rule.Ast.rule_id^"</div></h1></center>
<br/><br/><div id=doc>"^rule.Ast.rule_doc^"</div>"^
(* disable domain
(if (List.length ast.Ast.domain > 0) then (
"<h6>Features domain</h6><code class=\"code\">"^
(let rec compute tab = match tab with
| [] -> ""
| h::t -> begin match h with Ast.Open a -> "<b>"^a^"</b> : *<br/>"^compute t | Ast.Closed (name,values) -> "<b>"^name^"</b> : "^(AST_HTML.feat_values_tab_to_html values)^"<br/>"^compute t; end;
in compute ast.Ast.domain)
) else (
""
))^"</code>"^
*)
(* disable Labels
"<br/><h6>Labels</h6>"^
(if (List.length ast.Ast.labels > 0) then (
"<div class=\"h7\">Inherited from global</div>
<code class=\"code\">"^
(
let rec tab_to_html tab = match tab with
| [] -> ""
| h::[] -> h
| h::t -> h^", "^(tab_to_html t)
in tab_to_html (List.map fst ast.Ast.labels)
)^
"</code>"
) else ( ""))^
(if (List.length m.Ast.local_labels > 0) then (
"<div class=\"h7\">Locals</div>
<code class=\"code\">"^
(
let rec tab_to_html tab = match tab with
| [] -> ""
| h::[] -> h
| h::t -> h^", "^(tab_to_html t)
in tab_to_html (List.map fst m.Ast.local_labels)
)^
"</code>"
) else ( ""))^
*)
(*
"<br/>
<br/><h6>Commands</h6>
<code class=code><pre>"^(AST_HTML.to_html_commands_pretty rule.Ast.commands)^
*)
"
</pre></code><br/><h6>Code</h6><pre>"^
(AST_HTML.to_html_rules [rule])^
......@@ -158,7 +111,7 @@ let sequences_text ast =
)^
"</body>
</html>"
let index_modules_text ast =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
......@@ -257,13 +210,13 @@ in
"</body>
</html>"
let rec create_modules_table modules =
match modules with
| [] -> ""
| h::t ->
"<tr><td width=\"200px\"><a href=\""^h.Ast.module_id^".html\">"^h.Ast.module_id^"</a></td><td>"^h.Ast.module_doc^"</td></tr>\n"^
create_modules_table t
let rec create_modules_table modules =
match modules with
| [] -> ""
| h::t ->
"<tr><td width=\"200px\"><a href=\""^h.Ast.module_id^".html\">"^h.Ast.module_id^"</a></td><td>"^h.Ast.module_doc^"</td></tr>\n"^
create_modules_table t
let proceed output_dir ast =
ignore(Sys.command ("rm -rf "^output_dir));
......@@ -327,41 +280,20 @@ in
let rules_array = Array.of_list modules_array.(i).Ast.rules in
for j = 0 to (Array.length rules_array -1) do
(* let pattern_commands_view = Filename.concat output_dir (modules_array.(i).Ast.module_id^"_"^rules_array.(j).Ast.rule_id^"_pattern_commands") in *)
(* let antipattern_view = Filename.concat output_dir (modules_array.(i).Ast.module_id^"_"^rules_array.(j).Ast.rule_id^"antipattern_") in *)
(* let (patterns,antis) = (Ast.Grew_dot.to_dot_rule rules_array.(j)) in*)
(* let i2 = ref 0 in*)
(* let png = List.map (fun (title,dot) ->*)
(* let dot_file = pattern_commands_view^"_"^(string_of_int !i2) in*)
(* let page_out_ch = open_out dot_file in*)
(* output_string page_out_ch dot;*)
(* close_out page_out_ch;*)
(* ignore(Sys.command ("dot -Tpng -o"^pattern_commands_view^"_"^(string_of_int !i2)^".png "^dot_file));*)
(* let tmp = (title,(modules_array.(i).Ast.module_id^"_"^rules_array.(j).Ast.rule_id^"_pattern_commands")^"_"^(string_of_int !i2)) in*)
(* incr i2;*)
(* tmp*)
(* ) (List.rev patterns) in*)
(* *)
(* let index = ref 0 in*)
(* let antis = List.map (fun anti ->*)
(* let page_out_ch = open_out (antipattern_view^(string_of_int !index)) in*)
(* output_string page_out_ch anti;*)
(* close_out page_out_ch;*)
(* ignore(Sys.command ("dot -Tpng -o"^antipattern_view^(string_of_int !index)^".png "^antipattern_view^(string_of_int !index)));*)
(* incr index;*)
(* (modules_array.(i).Ast.module_id^"_"^rules_array.(j).Ast.rule_id^"antipattern_")^(string_of_int (!index-1))^".png"*)
(* ) antis in*)
let page = Filename.concat output_dir (modules_array.(i).Ast.module_id^"_"^rules_array.(j).Ast.rule_id^".html") in
let page_out_ch = open_out page in
output_string page_out_ch (rule_page_text (try Some (rules_array.(j-1).Ast.rule_id) with _ -> None) (try Some (rules_array.(j+1).Ast.rule_id) with _ -> None) rules_array.(j) modules_array.(i) ast (modules_array.(i).Ast.module_id^"_"^rules_array.(j).Ast.rule_id^".html"));
output_string page_out_ch
(rule_page_text
(try Some (rules_array.(j-1).Ast.rule_id) with _ -> None)
(try Some (rules_array.(j+1).Ast.rule_id) with _ -> None)
rules_array.(j)
modules_array.(i)
ast
(modules_array.(i).Ast.module_id^"_"^rules_array.(j).Ast.rule_id^".html")
);
close_out page_out_ch;
(* let page = Filename.concat output_dir (modules_array.(i).Ast.module_id^"_"^rules_array.(j).Ast.rule_id^".html_flatten.html") in*)
(* let page_out_ch = open_out page in*)
(* output_string page_out_ch (flatten_rule_page_text png output_dir);*)
(* close_out page_out_ch;*)
done;
done;
......
open Grew_ast
module Html :
sig
val proceed : string -> Ast.grs -> unit
end
......@@ -9,7 +9,7 @@ open Grew_rule
open Grew_grs
open Grew_parser
open HTMLer
open Grew_html
......@@ -38,7 +38,7 @@ let load_grs ?doc_output_dir file =
let grs_ast = Grew_parser.grs_of_file file in
(match doc_output_dir with
| None -> ()
| Some dir -> HTMLer.proceed dir grs_ast);
| Some dir -> Html.proceed dir grs_ast);
Grs.build grs_ast
with
| Grew_parser.Parse_error (msg,Some (sub_file,l)) ->
......
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