diff --git a/src/Makefile b/src/Makefile index a7e74af2d869b8075eacb331e36eb69d3df861b2..89a42f8acf04379f4d4dfda87e79da34f11500d7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -74,7 +74,7 @@ prof: test/ocamlprof.dump done grep: - rm test/ocamlprof.dump + rm test/ocamlprof.dump || true make clean make prof grep -n -e "(\* 0 \*)" prof/*.ml | grep -v "assert false" > dead.grep diff --git a/src/TODO b/src/TODO index 3bde6ceddc253fa614301fec06539320f7c021c8..dcf91dff703381809e1ffdd434d983966431d5c6 100644 --- a/src/TODO +++ b/src/TODO @@ -238,7 +238,6 @@ du code mort ou bien des tests - SymbolTab (20) - SyntaxTab (12) - SyntaxTree (7) - - SyntaxTreeDump (218) - UnifyClock (1) - UnifyType (37) - UniqueOutput (10) diff --git a/src/dead.grep b/src/dead.grep index e8d3ec95fc7060a951792aaf7a84b7e38a948337..6468ebfc8a6832e29aaee8b0348c6375c55df5bf 100644 --- a/src/dead.grep +++ b/src/dead.grep @@ -198,7 +198,7 @@ prof/lazyCompiler.ml:736: (* 0 *) raise (Compile_error (lxm, prof/lazyCompiler.ml:763: (* 0 *) raise (Compile_error (lxm, "can not alias this operator, sorry")) prof/lazyCompiler.ml:780: | UnifyType.Ko msg -> (* 0 *) raise(Compile_error(lxm, msg)) prof/lazyCompiler.ml:783: | UnifyType.Ko msg -> (* 0 *) raise(Compile_error (lxm, msg)) -prof/lazyCompiler.ml:788: let res = if !Global.one_op_per_equation then (* 797 *) Split.node res else (* 0 *) res in +prof/lazyCompiler.ml:788: let res = if !Global.one_op_per_equation then (* 798 *) Split.node res else (* 0 *) res in prof/licDump.ml:76: | Extern_const_eff (s,t,vopt) -> (* 0 *) (long s) ^ (string_of_const_eff_opt vopt) prof/licDump.ml:77: | Enum_const_eff (s,t) -> (* 0 *) (long s) prof/licDump.ml:78: | Struct_const_eff (fl, t) -> (* 0 *) ( @@ -224,7 +224,7 @@ prof/licDump.ml:445: | STRUCT_anonymous -> (* 0 *) "") ^ prof/licDump.ml:456: | SyntaxTreeCore.Base -> (* 0 *) "base" prof/licDump.ml:509: | AbstractEff -> (* 0 *) [] prof/licDump.ml:551: | AbstractEff -> (* 0 *) "" -prof/licDump.ml:553: (* 671 *) ((match neff.loclist_eff with None -> (* 0 *) "" | Some [] -> (* 174 *) "" +prof/licDump.ml:553: (* 672 *) ((match neff.loclist_eff with None -> (* 0 *) "" | Some [] -> (* 174 *) "" prof/licDump.ml:600:let node_error_string lxm nkey = (* 0 *) ( prof/licDump.ml:607:let print_compile_node_error nkey lxm msg = (* 0 *) ( prof/licDump.ml:613:let print_global_node_error lxm nkey msg = (* 0 *) ( @@ -232,8 +232,6 @@ prof/lxm.ml:28:let cstart x = (* 0 *) (x._cstart) prof/lxm.ml:29:let cend x = (* 0 *) (x._cend) prof/lxm.ml:30:let file x = (* 0 *) x._file prof/lxm.ml:31:let pragma x = (* 0 *) x._pragma -prof/main.ml:56:let print_version = function (x: unit) -> (* 0 *) ( -prof/main.ml:64: ( "--version", Arg.Unit(fun x -> (* 0 *) print_version () ; exit 0), prof/main.ml:67: ( "--output-file", Arg.String(fun x -> (* 0 *) Global.outfile := x), "<file>" prof/main.ml:69: ( "-o", Arg.String(fun x -> (* 0 *) Global.outfile := x), prof/main.ml:72: ( "--node", Arg.String(fun x -> (* 0 *) Global.main_node := x), @@ -245,19 +243,14 @@ prof/main.ml:95: ( "--verbose-level", Arg.Int(fun vl -> (* 0 *) Verbose.set_lev prof/main.ml:101: ( "--keep-nested-calls", Arg.Unit (fun _ -> (* 0 *) Global.one_op_per_equation := false), prof/main.ml:106: ("-h", Arg.Unit (fun _ -> (* 0 *) (Arg.usage arg_list usage_msg; exit 0)), "" ); prof/main.ml:108: ("--help", Arg.Unit (fun _ -> (* 0 *) (Arg.usage arg_list usage_msg; exit 0)), -prof/main.ml:120:let test_lex ( lexbuf ) = (* 0 *) ( -prof/main.ml:123: (* 0 *) match (Lexer.token_code !tk) with -prof/main.ml:125: (* 0 *) printf "%s : %15s = \"%s\"\n" -prof/main.ml:157: with _ -> (* 0 *) print_string ("*** '"^infile^"': bad file name.\n"); exit 1 -prof/main.ml:172: (* 0 *) get_remaining_source_list (maybe_pack, compiled, tail) -prof/main.ml:179: (* 0 *) print_string ("old-style (un-packaged) lustre files can " ^ -prof/main.ml:203: if Sys.file_exists !Global.outfile then (* 0 *) Sys.remove !Global.outfile; -prof/main.ml:213: if (!Global.infiles = []) then (* 0 *) ( -prof/main.ml:221: (* 0 *) Some (Ident.idref_of_string !Global.main_node) -prof/main.ml:223: if !Global.outfile <> "" then (* 0 *) Global.oc := open_out !Global.outfile; -prof/main.ml:230: (* 0 *) prerr_string (s^"\n"); -prof/main.ml:242: (* 0 *) prerr_string ( -prof/main.ml:246: (if List.length !Global.infiles > 1 then (* 0 *) "s " else (* 0 *) " ") ^ +prof/main.ml:146: with _ -> (* 0 *) print_string ("*** '"^infile^"': bad file name.\n"); exit 1 +prof/main.ml:168: (* 0 *) print_string ("old-style (un-packaged) lustre files can " ^ +prof/main.ml:192: if Sys.file_exists !Global.outfile then (* 0 *) Sys.remove !Global.outfile; +prof/main.ml:202: if (!Global.infiles = []) then (* 0 *) ( +prof/main.ml:210: (* 0 *) Some (Ident.idref_of_string !Global.main_node) +prof/main.ml:212: if !Global.outfile <> "" then (* 0 *) Global.oc := open_out !Global.outfile; +prof/main.ml:231: (* 0 *) prerr_string ( +prof/main.ml:235: (if List.length !Global.infiles > 1 then (* 0 *) "s " else (* 0 *) " ") ^ prof/parserUtils.ml:132:let ternexp lxm op e1 e2 e3 = (* 0 *) CallByPos( {src = lxm ; it = op }, Oper [e1 ; e2; e3] ) prof/parserUtils.ml:151: (* 0 *) print_string ("Parser.idref_of_lxm" ^(Lxm.str lxm)); prof/parserUtils.ml:463: (* 0 *) CallByPos(flagit (IDENT_n (Ident.idref_of_string(istr))) lxm, @@ -392,7 +385,7 @@ prof/syntaxTree.ml:127: | LeftSlice (x, _) -> (* 0 *) lexeme_of_left_part x prof/syntaxTree.ml:133: | NSPack pi -> (* 0 *) Ident.pack_name_to_string pi.it.pa_name ^ " (pack) " prof/syntaxTree.ml:134: | NSModel mi -> (* 0 *) Ident.pack_name_to_string mi.it.mo_name ^ " (model) " prof/unifyClock.ml:27: (* 1749 *) if List.mem_assoc i s then (* 0 *) s else (* 1749 *) (i,c)::s -prof/unifyType.ml:47: (* 1515 *) if l1 <> l2 then (* 0 *) Ko "\n*** incompatible structure" else +prof/unifyType.ml:47: (* 1766 *) if l1 <> l2 then (* 0 *) Ko "\n*** incompatible structure" else prof/unifyType.ml:107: | Ko(msg) -> (* 0 *) msg prof/unifyType.ml:108: | Equal -> (* 0 *) "types are equals\n" prof/unifyType.ml:109: | Unif t -> (* 0 *) "types are unifiable via " ^ (teff2str t) ^ "\n" @@ -406,4 +399,4 @@ prof/uniqueOutput.ml:83: (* 0 *) let msg = "\n*** Variable " ^ v ^ " is define prof/uniqueOutput.ml:186: (* 0 *) let msg = "\n*** Undefined variable(s): " ^ prof/uniqueOutput.ml:201: (* 0 *) let msg = "\n*** Error; " ^(id2str v.var_name_eff) ^ prof/uniqueOutput.ml:211: (* 0 *) let msg = "\n*** Undefined variable: " ^ (id2str v.var_name_eff) -prof/verbose.ml:34: (fun t -> (* 2824 *) if (!_level >= level) then (* 0 *) (print_string t; flush stdout) else (* 2824 *) ()) s +prof/verbose.ml:34: (fun t -> (* 2837 *) if (!_level >= level) then (* 0 *) (print_string t; flush stdout) else (* 2837 *) ()) s diff --git a/src/main.ml b/src/main.ml index 542e9625c3beb4016bb2741cac9c1844309aaf85..85a16b152401cd7719b90be5bb3fddaebae722ae 100644 --- a/src/main.ml +++ b/src/main.ml @@ -1,4 +1,4 @@ -(** Time-stamp: <modified the 15/09/2008 (at 18:07) by Erwan Jahier> *) +(** Time-stamp: <modified the 17/09/2008 (at 11:50) by Erwan Jahier> *) (** Here follows a description of the different modules used by this lus2lic compiler. @@ -117,17 +117,6 @@ and () ) -let test_lex ( lexbuf ) = ( - let tk = ref (Lexer.lexer lexbuf) in ( - while !tk <> Parser.TK_EOF do - match (Lexer.token_code !tk) with - ( co , lxm ) -> - printf "%s : %15s = \"%s\"\n" - (Lxm.position lxm) co (Lxm.str lxm) ; - tk := (Lexer.lexer lexbuf) - done - ) -) (* Retourne un parse_tree *) let lus_load lexbuf = ( diff --git a/src/test/Makefile b/src/test/Makefile index 32ca6e2d57d20e0e94f754ace2364788ce7ac0b3..453fcbf398dfba0ee2a27b311da56ae2fc44cde7 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -37,18 +37,29 @@ xxx: $(LC2) $$d > /dev/null ;\ done + +begin: + echo "Non-regression tests" > test_ok.res + echo "Those tests are supposed to generate errors" > test_ko.res + + unit: - $(LC0) -unit + $(LC0) -unit >> test_ok.res 2>&1 help: - $(LC0) -help + $(LC0) -help >> test_ok.res 2>&1 -toto: - $(LC2) toto.lus -o toto.lic | $(filter_line) +version: + $(LC0) --version -test: unit help - echo "Non-regression tests" > test_ok.res - echo "Those tests are supposed to generate errors" > test_ko.res + +do_not_exist: + $(LC) do_not_exist.lus >> test_ko.res 2>&1 || true + +same_file: + $(LC) should_work/NONREG/ex.lus should_work/NONREG/ex.lus >> test_ok.res 2>&1 + +test: begin unit help version do_not_exist same_file for d in ${OK_LUS}; do \ echo -e "\n$(NL)====> $(LC) $$d" >> test_ok.res; \ $(LC) $$d >> test_ok.res 2>&1 ;\ diff --git a/src/test/should_fail/syntax/old_style_and_pack.lus b/src/test/should_fail/syntax/old_style_and_pack.lus new file mode 100644 index 0000000000000000000000000000000000000000..1b070373375b3ea9e1193275050712482ddeb840 --- /dev/null +++ b/src/test/should_fail/syntax/old_style_and_pack.lus @@ -0,0 +1,20 @@ + + +package toto + +provides + node titi(x:int) returns (y:int); + +body + + node titi(x:int) returns (y:int); + let + y = x + 2; + tel +end + + +node main(x:int) returns (y:int); + let + y = toto: : titi(x); + tel \ No newline at end of file diff --git a/src/test/test.res.exp b/src/test/test.res.exp index 75b722eba94b2ba0a37914c7dc67cc2b0846ebd3..f0dd72d425075aca0931cdced08759384f135c52 100644 --- a/src/test/test.res.exp +++ b/src/test/test.res.exp @@ -1,4 +1,62 @@ Non-regression tests +usage: lus2lic [options] <lustre files> | lus2lic -help + --version Print the current version then exit + --output-file <file> + -o <file> Set the output file name + --node <node> + -n <node> Set the main node (all items are compiled if unset) + --compile-all-items + -all Compile all items of the program + -unit Run some (internal) unit tests + --verbose + -v Set verbose mode on (i.e., verbose level = 1) + --verbose-level <int> + -vl <int> Set verbose level + --keep-nested-calls Keep nested calls + -h + -help + --help Display this list of options +Opening file should_work/NONREG/ex.lus +type _ex::t = A_A_A_int_1_2_3^4; +type _ex::t1 = A_A_A_A_int_1_2_3_4^4; +type _ex::t2 = struct {a : int; b : A_A_bool_11_22}; +type _ex::s1 = struct {x : int; y : A_A_A_A_int_1_2_3_4}; +type _ex::s = struct {x : A_A_A_A_int_1_2_3_4; y : _ex::s1}; +node ex::ex(a:_ex::s) returns (b:int); +var + _v1:A_A_A_A_int_1_2_3_4; + _v2:A_A_A_int_1_2_3; + _v3:A_A_int_1_2; + _v4:A_int_1; + _v5:int; + _v6:_ex::s1; + _v7:A_A_A_A_int_1_2_3_4; + _v8:A_A_A_int_1_2_3; + _v9:A_A_int_1_2; + _v10:A_int_1; + _v11:int; +let + b = _v5 + _v11; + _v1 = a.x; + _v2 = _v1[0]; + _v3 = _v2[0]; + _v4 = _v3[0]; + _v5 = _v4[0]; + _v6 = a.y; + _v7 = _v6.y; + _v8 = _v7[0]; + _v9 = _v8[0]; + _v10 = _v9[0]; + _v11 = _v10[0]; +tel +-- end of node ex::ex +-- automatically defined aliases: +type A_A_A_A_int_1_2_3_4 = A_A_A_int_1_2_3^4; +type A_A_bool_11_22 = A_bool_11^22; +type A_bool_11 = bool^11; +type A_A_A_int_1_2_3 = A_A_int_1_2^3; +type A_A_int_1_2 = A_int_1^2; +type A_int_1 = int^1; ---------------------------------------------------------------------- ====> ../lus2lic -vl 2 --compile-all-items should_work/NONREG/CURRENT.lus @@ -18428,6 +18486,8 @@ tel -- end of node asservi::asservi Those tests are supposed to generate errors +Opening file do_not_exist.lus +do_not_exist.lus: No such file or directory ---------------------------------------------------------------------- ====> ../lus2lic -vl 2 --compile-all-items should_fail/clock/bad_call02.lus @@ -18905,6 +18965,13 @@ Opening file should_fail/semantics/x.lus > const ref in file "should_fail/semantics/x.lus", line 2, col 11 to 11, token 'm' +---------------------------------------------------------------------- +====> ../lus2lic -vl 2 --compile-all-items should_fail/syntax/old_style_and_pack.lus +Opening file should_fail/syntax/old_style_and_pack.lus +*** Error in file "should_fail/syntax/old_style_and_pack.lus", line 17, col 1 to 4, token 'node': +*** syntax error + + ---------------------------------------------------------------------- ====> ../lus2lic -vl 2 --compile-all-items should_fail/syntax/record.lus Opening file should_fail/syntax/record.lus diff --git a/src/untested_line_counter b/src/untested_line_counter index 0c50dfe60bc7cd24420b9f194c09268c1c55bcb3..0d9e56e7d69c28e5e57dba0bbdb2bf543f45d9cf 100644 --- a/src/untested_line_counter +++ b/src/untested_line_counter @@ -1 +1 @@ - 409 4185 32814 dead.grep + 402 4118 32317 dead.grep