Skip to content
Snippets Groups Projects
Commit 31a23448 authored by Wilke Pierre's avatar Wilke Pierre
Browse files

Passage à dune et OCaml 4.14

parent c5cf3dc3
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,8 @@ grammar.html ...@@ -3,7 +3,8 @@ grammar.html
src/generated_parser.ml src/generated_parser.ml
src/config.ml src/config.ml
**/*.native **/*.native
ecomp
skeleton skeleton
src/.vscode/ src/.vscode/
.vscode/ .vscode/
Makefile.config Makefile.config
\ No newline at end of file
all: main.native all: ecomp
include opts.mk include opts.mk
.PHONY: main.native .PHONY: ecomp
src/config.ml: configure opts.mk src/config.ml: configure opts.mk
./configure ${CONF_OPTS} ./configure ${CONF_OPTS}
main.native: src/config.ml .PHONY: alpaga
alpaga/alpaga:
make -C alpaga make -C alpaga
src/generated_parser.ml: expr_grammar_action.g alpaga/alpaga
./alpaga/alpaga \ ./alpaga/alpaga \
-g expr_grammar_action.g \ -g expr_grammar_action.g \
-pml src/generated_parser.ml \ -pml src/generated_parser.ml \
-t grammar.html -t grammar.html
ecomp: src/generated_parser.ml src/config.ml
make -C src make -C src
ln -sf src/main.native main.native ln -sf src/_build/default/main.exe ecomp
clean: clean:
make -C alpaga clean make -C alpaga clean
rm -f src/generated_parser.ml rm -f src/generated_parser.ml
rm -f grammar.html rm -f grammar.html
make -C src clean make -C src clean
rm -f main.native rm -f ecomp
make -C tests clean make -C tests clean
test: main.native test: ecomp
make -C tests make -C tests
No preview for this file type
S .
B _build
PKG batteries
\ No newline at end of file
OCB=ocamlbuild -use-ocamlfind -cflag -g #OCB=ocamlbuild -use-ocamlfind -cflag -g
SRC=ml_parser_generator.ml \ SRC=ml_parser_generator.ml \
grammar_parser.ml \ grammar_parser.ml \
...@@ -12,11 +12,9 @@ TG = alpaga ...@@ -12,11 +12,9 @@ TG = alpaga
all: $(TG) all: $(TG)
$(TG): ml_parser_generator.native $(TG): $(SRC)
cp ml_parser_generator.native $(TG) dune build ml_parser_generator.exe
ln -sf _build/default/ml_parser_generator.exe alpaga
ml_parser_generator.native: $(SRC)
$(OCB) ml_parser_generator.native
clean: clean:
rm -f ml_parser_generator.native $(TG) rm -f ml_parser_generator.native $(TG)
......
<.>: include
true: package(str, batteries)
true: use_menhir
(menhir
(modules grammar_parser_yacc)
)
(ocamllex grammar_lexer)
(executable
(name ml_parser_generator)
(libraries
batteries
menhirLib
)
(flags (:standard -warn-error -A -w -27 -w -33 -w -9 -w -39))
)
(lang dune 2.9)
(using menhir 2.1)
...@@ -24,5 +24,6 @@ let dump_grammar oc (toks, nts, rules) = ...@@ -24,5 +24,6 @@ let dump_grammar oc (toks, nts, rules) =
Printf.fprintf oc "\nnon-terminals "; Printf.fprintf oc "\nnon-terminals ";
List.iter (fun n -> Printf.fprintf oc " %s" n) nts; List.iter (fun n -> Printf.fprintf oc " %s" n) nts;
Printf.fprintf oc "\nrules\n"; Printf.fprintf oc "\nrules\n";
List.iter (fun (n,lt,a) -> Printf.fprintf oc "%s ->%s\n" n (print_seq (fun x -> x) lt)) rules List.iter (fun (n,lt,_) ->
Printf.fprintf oc "%s ->%s\n" n (print_seq (fun x -> x) lt)) rules
S .
B _build
PKG lwt
PKG lwt.unix
PKG logs
PKG logs.lwt
PKG batteries
PKG yojson
PKG websocket
PKG websocket-lwt-unix
PKG menhirLib
\ No newline at end of file
...@@ -9,18 +9,18 @@ ltl_gen.ml ltl_run.ml ltl_debug.ml main.ml options.ml parser.ml prog.ml \ ...@@ -9,18 +9,18 @@ ltl_gen.ml ltl_run.ml ltl_debug.ml main.ml options.ml parser.ml prog.ml \
regalloc.ml report.ml riscv.ml rtl.ml rtl_print.ml rtl_gen.ml rtl_run.ml \ regalloc.ml report.ml riscv.ml rtl.ml rtl_print.ml rtl_gen.ml rtl_run.ml \
symbols.ml tokenize.ml utils.ml symbols.ml tokenize.ml utils.ml
TG = main.native TG = main.exe
PROF:=$(if $(PROF),-ocamlopt ocamloptp,) PROF:=$(if $(PROF),-ocamlopt ocamloptp,)
all: $(TG) all: $(TG)
$(TG): $(SRC) $(TG): $(SRC)
ocamlbuild $(PROF) -cflags -warn-error,"+a-26" -cflags -w,"-26" -menhir "menhir --unused-tokens" -use-ocamlfind $(TG) dune build $(TG)
# ocamlbuild $(PROF) -cflags -warn-error,"+a-26" -cflags -w,"-26" -menhir "menhir --unused-tokens" -use-ocamlfind $(TG)
test_lexer: archi.ml config.ml e_regexp.ml lexer_generator.ml symbols.ml test_lexer.ml utils.ml test_lexer: archi.ml config.ml e_regexp.ml lexer_generator.ml symbols.ml test_lexer.ml utils.ml
ocamlbuild -use-ocamlfind test_lexer.native dune exec test_lexer.exe
./test_lexer.native
dot -Tsvg /tmp/dfa.dot -o /tmp/dfa.svg dot -Tsvg /tmp/dfa.dot -o /tmp/dfa.svg
dot -Tsvg /tmp/nfa.dot -o /tmp/nfa.svg dot -Tsvg /tmp/nfa.dot -o /tmp/nfa.svg
...@@ -28,5 +28,5 @@ config.ml: ../configure ../opts.mk ...@@ -28,5 +28,5 @@ config.ml: ../configure ../opts.mk
cd .. && ./configure ${CONF_OPTS} cd .. && ./configure ${CONF_OPTS}
clean: clean:
rm -rf _build dune clean
rm -f config.ml main.native test_lexer.native rm -f config.ml
true: debug
true: bin_annot
<runtime>: -traverse
<*>: package(lwt lwt.unix logs logs.lwt batteries yojson websocket websocket-lwt-unix menhirLib)
true: thread
true: use_menhir, explain, table
<tykernel>: -traverse
open Config
type archi = A64 | A32 type archi = A64 | A32
......
open Batteries open Batteries
open BatPrintf
(* Les AST sont des arbres, du type [tree], étiquetés par des [tag]. (* Les AST sont des arbres, du type [tree], étiquetés par des [tag].
...@@ -31,7 +30,7 @@ type tag = Tassign | Tif | Twhile | Tblock | Treturn | Tprint ...@@ -31,7 +30,7 @@ type tag = Tassign | Tif | Twhile | Tblock | Treturn | Tprint
| Tlistglobdef | Tlistglobdef
| Tfundef | Tfunname | Tfunargs | Tfunbody | Tfundef | Tfunname | Tfunargs | Tfunbody
| Tassignvar | Tassignvar
| Targ | Targ
type tree = | Node of tag * tree list type tree = | Node of tag * tree list
| StringLeaf of string | StringLeaf of string
......
open Elang open Elang
open Prog open Prog
open Utils
open Batteries open Batteries
open BatList open BatList
...@@ -51,10 +50,10 @@ let preds cfgfunbody n = ...@@ -51,10 +50,10 @@ let preds cfgfunbody n =
) cfgfunbody Set.empty ) cfgfunbody Set.empty
let size_binop b e1 e2 = let size_binop _ e1 e2 =
1 + e1 + e2 1 + e1 + e2
let size_unop u e = let size_unop _ e =
1 + e 1 + e
let rec size_expr (e: expr) : int = let rec size_expr (e: expr) : int =
...@@ -62,16 +61,16 @@ let rec size_expr (e: expr) : int = ...@@ -62,16 +61,16 @@ let rec size_expr (e: expr) : int =
| Ebinop (b, e1, e2) -> size_binop b (size_expr e1) (size_expr e2) | Ebinop (b, e1, e2) -> size_binop b (size_expr e1) (size_expr e2)
| Eunop (u, e) -> size_unop u (size_expr e) | Eunop (u, e) -> size_unop u (size_expr e)
| Eint _ -> 1 | Eint _ -> 1
| Evar v -> 1 | Evar _ -> 1
let rec size_instr (i: cfg_node) : int = let size_instr (i: cfg_node) : int =
match (i : cfg_node) with match (i : cfg_node) with
| Cassign (v, e, s) -> 1 + size_expr e | Cassign (_, e, _) -> 1 + size_expr e
| Creturn e -> 1 + (size_expr e) | Creturn e -> 1 + (size_expr e)
| Cprint (e, s) -> 1 + (size_expr e) | Cprint (e, _) -> 1 + (size_expr e)
| Ccmp (e, s1, s2) -> 1 + size_expr e | Ccmp (e, _, _) -> 1 + size_expr e
| Cnop s -> 1 | Cnop _ -> 1
let size_fun f = let size_fun f =
Hashtbl.fold (fun k v acc -> acc + size_instr v) f 0 Hashtbl.fold (fun _ v acc -> acc + size_instr v) f 0
...@@ -37,8 +37,8 @@ let rec const_prop_expr (e: expr) = ...@@ -37,8 +37,8 @@ let rec const_prop_expr (e: expr) =
let constant_propagation_instr (i: cfg_node) : cfg_node = let constant_propagation_instr (i: cfg_node) : cfg_node =
i i
let constant_propagation_fun ({ cfgfunargs; cfgfunbody; cfgentry } as f: cfg_fun) = let constant_propagation_fun ({ cfgfunbody; _ } as f: cfg_fun) =
let ht = Hashtbl.map (fun n m -> let ht = Hashtbl.map (fun _ m ->
constant_propagation_instr m constant_propagation_instr m
) cfgfunbody in ) cfgfunbody in
{ f with cfgfunbody = ht} { f with cfgfunbody = ht}
......
...@@ -13,7 +13,7 @@ open Options ...@@ -13,7 +13,7 @@ open Options
function [f]. Cette fonction renvoie un couple [(f',c)] oú [f'] est la function [f]. Cette fonction renvoie un couple [(f',c)] oú [f'] est la
nouvelle fonction, et [c] est un booléen qui indique si du progrès a été nouvelle fonction, et [c] est un booléen qui indique si du progrès a été
fait. *) fait. *)
let dead_assign_elimination_fun ({ cfgfunargs; cfgfunbody; cfgentry } as f: cfg_fun) = let dead_assign_elimination_fun ({ cfgfunbody; _ } as f: cfg_fun) =
let changed = ref false in let changed = ref false in
let cfgfunbody = let cfgfunbody =
Hashtbl.map (fun (n: int) (m: cfg_node) -> Hashtbl.map (fun (n: int) (m: cfg_node) ->
......
...@@ -106,7 +106,7 @@ let cfg_gdef_of_edef gd = ...@@ -106,7 +106,7 @@ let cfg_gdef_of_edef gd =
Gfun f -> cfg_fun_of_efun f >>= fun f -> OK (Gfun f) Gfun f -> cfg_fun_of_efun f >>= fun f -> OK (Gfun f)
let cfg_prog_of_eprog (ep: eprog) : cfg_fun prog res = let cfg_prog_of_eprog (ep: eprog) : cfg_fun prog res =
assoc_map_res (fun fname -> cfg_gdef_of_edef) ep assoc_map_res (fun _ -> cfg_gdef_of_edef) ep
let pass_cfg_gen ep = let pass_cfg_gen ep =
match cfg_prog_of_eprog ep with match cfg_prog_of_eprog ep with
......
open Batteries open Batteries
open Cfg open Cfg
open Prog
open Utils
(* Analyse de vivacité *) (* Analyse de vivacité *)
......
...@@ -2,7 +2,6 @@ open Batteries ...@@ -2,7 +2,6 @@ open Batteries
open Cfg open Cfg
open Elang_print open Elang_print
open Prog open Prog
open Utils
let rec dump_cfgexpr : expr -> string = function let rec dump_cfgexpr : expr -> string = function
| Ebinop(b, e1, e2) -> Format.sprintf "(%s %s %s)" (dump_cfgexpr e1) (dump_binop b) (dump_cfgexpr e2) | Ebinop(b, e1, e2) -> Format.sprintf "(%s %s %s)" (dump_cfgexpr e1) (dump_binop b) (dump_cfgexpr e2)
...@@ -44,7 +43,7 @@ let dump_liveness_state oc ht state = ...@@ -44,7 +43,7 @@ let dump_liveness_state oc ht state =
flush_all () flush_all ()
) ht ) ht
let dump_cfg_fun oc cfgfunname ({ cfgfunargs; cfgfunbody; cfgentry; }: cfg_fun) = let dump_cfg_fun oc cfgfunname ({ cfgfunbody; cfgentry; _ }: cfg_fun) =
Format.fprintf oc "subgraph cluster_%s {\n label=\"%s\";\n" cfgfunname cfgfunname; Format.fprintf oc "subgraph cluster_%s {\n label=\"%s\";\n" cfgfunname cfgfunname;
Hashtbl.iter (fun n node -> Hashtbl.iter (fun n node ->
Format.fprintf oc "n_%s_%d [label=\"%a\" xlabel=\"%d\" shape=%s];\n" cfgfunname n dump_cfg_node node n (if n = cfgentry then "rectangle peripheries=2" else "rectangle"); Format.fprintf oc "n_%s_%d [label=\"%a\" xlabel=\"%d\" shape=%s];\n" cfgfunname n dump_cfg_node node n (if n = cfgentry then "rectangle peripheries=2" else "rectangle");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment