diff --git a/Makefile b/Makefile index 38b0bbea9b1674f3750b32c5c29749c8c43bc8f6..6862c2a62064b977ddd7575be641af85cf0b663f 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,7 @@ SOC_SOURCES = \ COMPILER_SOURCES = \ $(OBJDIR)/version.ml \ $(OBJDIR)/verbose.mli \ + $(OBJDIR)/util.ml \ $(OBJDIR)/genlex.mli \ $(OBJDIR)/genlex.ml \ $(OBJDIR)/verbose.ml \ @@ -126,6 +127,7 @@ LDBG_SOURCES = \ ln_ldbg: $(OBJDIR) $(LDBG_SOURCES) ldbg : ln_ldbg make -f Makefile.lib4lurette ncl + make -f Makefile.lib4lurette bcl # # Be sure to build those files before doing something else diff --git a/Makefile.lib4lurette b/Makefile.lib4lurette index 53bb985e03a48d23ac5b8ed6d359941ec21c91d9..fb044309d45d5b71c1ad75e3641cfdf88c638f71 100644 --- a/Makefile.lib4lurette +++ b/Makefile.lib4lurette @@ -4,4 +4,4 @@ include ./Makefile SOURCES = $(LDBG_SOURCES) -all: ncl +all: ncl bcl diff --git a/src/data.ml b/src/data.ml index a15191599ac0b723fbd03dfe8465b793624e04d8..44b0ef47e578ce0d0f418db5656974ae380da2d5 100644 --- a/src/data.ml +++ b/src/data.ml @@ -16,7 +16,7 @@ type t = let rec (val_to_string : v -> string) = function | I i -> string_of_int i - | F f -> string_of_float f (* Util.my_string_of_float f *) + | F f -> Util.my_string_of_float f | B true -> "t" | B false -> "f" | E (e,_) -> e diff --git a/src/event.ml b/src/event.ml deleted file mode 120000 index 1c18f00017d226956c333c45764f992158844e22..0000000000000000000000000000000000000000 --- a/src/event.ml +++ /dev/null @@ -1 +0,0 @@ -/home/jahier/lurette/source/Lurettetop/event.ml \ No newline at end of file diff --git a/src/event.ml b/src/event.ml new file mode 100644 index 0000000000000000000000000000000000000000..b1a8c26e7538a6b73dd9b58c942bc323787f631a --- /dev/null +++ b/src/event.ml @@ -0,0 +1,79 @@ +type ctx = (* inherited debug info *) + { + ctx_step :int; + ctx_name :string; + ctx_depth:int; + ctx_data: Data.subst list; + ctx_terminate: unit -> unit; + ctx_inputs : string list; + ctx_outputs : string list; + } + + +type src_info = { + str : string ; + file : string ; + line : int * int ; + char : int * int ; + stack : src_info option; +} + + +(* Source info related to the elected constraint *) +type cstr_lazy_src_info = (unit -> src_info list) +type port = + | Call + | Exit of string * Expr.t (* The elected contraint that produced the outputs *) * cstr_lazy_src_info + | Fail of string * Expr.t (* The elected contraint that failed *) * cstr_lazy_src_info * + (unit -> Failure.info) + + +type node_info = { + port : port; + name : string; + lang : string; + inputs : string list; (* static info *) + outputs : string list; (* static info *) +} + +type kind = + | Node of node_info + | Ltop + +(* when an elected constraint is unsatisfiable *) + +type t = { + nb:int; + step : int; + depth : int; + kind : kind; + data : Data.subst list; + other : string; + next : unit -> t; + terminate: unit -> unit; +} + (* ou bien un MapString ? + ou bien une structure avec tout un tas d'autre info ? + devra etre abrait en tout cas + *) + + +exception End of int +let (next : t -> t) = fun e -> e.next () +let (terminate : t -> unit) = fun e -> e.terminate () +let (data : t -> Data.subst list) = fun e -> e.data + + +let seed = ref 42 +let set_seed s = seed := s + +let event_nb = ref 0 +let set_nb i = event_nb := i +let get_nb () = !event_nb +let incr_nb() = + Random.init (!seed + !event_nb); (* make sure everything is reproductible *) + incr event_nb + + + + diff --git a/src/expr.ml b/src/expr.ml deleted file mode 120000 index bda437aae968fb295359cdd0a48c9176b533c1f4..0000000000000000000000000000000000000000 --- a/src/expr.ml +++ /dev/null @@ -1 +0,0 @@ -/home/jahier/lurette/source/Lurettetop/expr.ml \ No newline at end of file diff --git a/src/expr.ml b/src/expr.ml new file mode 100644 index 0000000000000000000000000000000000000000..e347e1802b4865f00cd670de4d496c0f2f782c3d --- /dev/null +++ b/src/expr.ml @@ -0,0 +1,86 @@ + + +(* Expressions *) +type t = + | Op of oper * t list + | True | False + | Ival of Num.num | Fval of float + | Var of string +and + oper = + | And | Or | Xor | Impl | Not | Eq | Ite + | Sup | SupEq | Inf | InfEq + | Sum | Diff | Prod | Quot | Mod | Div | Uminus + | Call of string + +let (to_string : t -> string) = + fun t -> + let rec aux b t = + let b = " "^b in + (match t with + | Op(And,[e1;e2]) -> (aux b e1)^" and " ^(aux b e2) + | Op(Or,[e1;e2]) -> "("^(aux b e1)^" or " ^(aux b e2) ^ ")" + | Op(Xor,[e1;e2]) -> "("^(aux b e1)^" xor" ^(aux b e2) ^ ")" + | Op(Impl,[e1;e2]) -> "("^(aux b e1)^" =>" ^(aux b e2) ^ ")" + | Op(Not,[e]) -> "not(" ^(aux b e) ^")" + | Op(Eq,[e1;e2]) -> (aux b e1)^ "=" ^(aux b e2) + (* | Op(Ite,[c;e1;e2]) -> "("^(aux b e1)^"ite" ^(aux b e2) *) + | Op(Sup,[e1;e2]) -> (aux b e1)^">" ^(aux b e2) + | Op(SupEq,[e1;e2]) -> (aux b e1)^">=" ^(aux b e2) + | Op(Inf,[e1;e2]) -> (aux b e1)^"<" ^(aux b e2) + | Op(InfEq,[e1;e2]) -> (aux b e1)^"<=" ^(aux b e2) + | Op(Sum,[e1;e2]) -> "("^(aux b e1)^"+" ^(aux b e2) ^ ")" + | Op(Diff,[e1;e2]) -> "("^(aux b e1)^"-" ^(aux b e2) ^ ")" + | Op(Prod,[e1;e2]) -> (aux b e1)^"*" ^(aux b e2) + | Op(Quot,[e1;e2]) -> (aux b e1)^"/" ^(aux b e2) + | Op(Mod,[e1;e2]) -> "("^(aux b e1)^"mod" ^(aux b e2) ^ ")" + | Op(Div,[e1;e2]) -> (aux b e1)^"/" ^(aux b e2) + + | Op (op,l) -> (oper_aux b op) ^ "(\n"^b ^ + ((String.concat (",\n"^b) (List.map (aux b) l))^"\n"^b^")") + | True -> "t" + | False -> "f" + | Ival(n) -> Num.string_of_num n + | Fval(f) -> string_of_float f + | Var(str) -> str + ) + and + oper_aux b = function + | And -> "and" + | Or -> "or" + | Xor -> "xor" + | Impl -> "impl" + | Not -> "not" + | Eq -> "eq" + | Ite -> "ite" + | Sup -> "sup" + | SupEq -> "supeq" + | Inf -> "inf" + | InfEq -> "infeq" + | Sum -> "sum" + | Diff -> "diff" + | Prod -> "prod" + | Quot -> "quot" + | Mod -> "mod" + | Div -> "div" + | Uminus -> "uminus" + | Call str -> str + in + aux "" t + +let dump e = + print_string ((to_string e)^ "\n") + +let rec (simplify : t -> t) = + fun t -> + match t with + | Op(And, (Op(And,l)::tail)) -> simplify (Op(And, (l@tail))) + | Op(Or, (Op(Or,l)::tail)) -> simplify (Op(Or, (l@tail))) + | Op(Sum, (Op(Sum,l)::tail)) -> simplify (Op(Sum, (l@tail))) + | Op(Not,[Op(Not, [e])]) -> simplify e + | Op(Not,[Op(Sup, [e1;e2])]) -> Op(InfEq, [simplify e1;simplify e2]) + | Op(Not,[Op(Inf, [e1;e2])]) -> Op(SupEq, [simplify e1;simplify e2]) + | Op(Not,[Op(SupEq, [e1;e2])]) -> Op(Inf, [simplify e1;simplify e2]) + | Op(Not,[Op(InfEq, [e1;e2])]) -> Op(Sup, [simplify e1;simplify e2]) + | Op (op,l) -> Op (op, List.map simplify l) + | e -> e diff --git a/src/util.ml b/src/util.ml new file mode 100644 index 0000000000000000000000000000000000000000..a41b98464b2417f2ff54a60fa48a075621f30705 --- /dev/null +++ b/src/util.ml @@ -0,0 +1,2 @@ + +let my_string_of_float = string_of_float diff --git a/test/lus2lic.sum b/test/lus2lic.sum index 0842f20b0af01ae4bfb0f896ac7ed67fbf8e2b38..0aca87d7c13a71cea18ea1149715c3757a8895ae 100644 --- a/test/lus2lic.sum +++ b/test/lus2lic.sum @@ -1,4 +1,4 @@ -Test Run By jahier on Tue Apr 9 18:30:52 2013 +Test Run By jahier on Wed Apr 10 16:00:15 2013 Native configuration is i686-pc-linux-gnu === lus2lic tests ===