From 49ff639a78c0db124c318436bed95d3f137b1baa Mon Sep 17 00:00:00 2001 From: Erwan Jahier <jahier@imag.fr> Date: Thu, 6 Mar 2008 16:16:45 +0100 Subject: [PATCH] Remove support for using predefined operator as nodes. i.e., a = operator +(1,3); or a = map<<operator +>>(l); This is to simplify the syntax tree. We migth undo this change in the future, or perform the same thing differently. --- src/evalNode.ml | 8 +++----- src/expandPack.ml | 7 +++---- src/lazyCompiler.ml | 18 +++--------------- src/parser.mly | 22 +++++++++++++--------- src/syntaxTreeCore.ml | 5 ++--- src/syntaxTreeDump.ml | 24 +++++++++--------------- src/test/should_work/Pascal/t.lus | 4 ++-- src/test/should_work/Pascal/t1.lus | 2 +- src/test/should_work/Pascal/t2.lus | 6 +++--- src/test/test.res.exp | 7 ++----- 10 files changed, 41 insertions(+), 62 deletions(-) diff --git a/src/evalNode.ml b/src/evalNode.ml index 08976eb0..6c4a1fc6 100644 --- a/src/evalNode.ml +++ b/src/evalNode.ml @@ -1,4 +1,4 @@ -(** Time-stamp: <modified the 20/02/2008 (at 16:06) by Erwan Jahier> *) +(** Time-stamp: <modified the 06/03/2008 (at 15:15) by Erwan Jahier> *) open SyntaxTree @@ -7,9 +7,7 @@ open CompiledData let rec (f : CompiledData.id_solver -> SyntaxTreeCore.node_exp -> CompiledData.node_eff) = - fun id_solver ne -> - match ne with - | CallPreDef predef_node -> PredefEff predef_node - | CallUsrDef (idref, static_args) -> assert false + fun id_solver (idref, static_args) -> + assert false diff --git a/src/expandPack.ml b/src/expandPack.ml index 00f12c54..79048e0d 100644 --- a/src/expandPack.ml +++ b/src/expandPack.ml @@ -1,4 +1,4 @@ -(** Time-stamp: <modified the 15/02/2008 (at 10:36) by Erwan Jahier> *) +(** Time-stamp: <modified the 06/03/2008 (at 15:15) by Erwan Jahier> *) open Lxm open SyntaxTree @@ -84,10 +84,9 @@ let (doit: | StaticParamNode (s,inl,outl,has_memory) -> ( let ne = match (a.it) with StaticArgIdent idr -> ( - Lxm.flagit (CallUsrDef (idr,[])) a.src + Lxm.flagit ((idr,[])) a.src ) - | - StaticArgNode x -> Lxm.flagit x a.src + | StaticArgNode x -> Lxm.flagit x a.src | _ -> instance_error () in let ni = Node { diff --git a/src/lazyCompiler.ml b/src/lazyCompiler.ml index 8c25f2d1..c3cd9d5d 100644 --- a/src/lazyCompiler.ml +++ b/src/lazyCompiler.ml @@ -1,4 +1,4 @@ -(** Time-stamp: <modified the 06/03/2008 (at 10:05) by Erwan Jahier> *) +(** Time-stamp: <modified the 06/03/2008 (at 15:17) by Erwan Jahier> *) open Lxm @@ -530,20 +530,8 @@ and (node_check_do: t -> CompiledData.node_key -> Lxm.t -> SymbolTab.t -> match node_def.it with | Node n -> (match n.uni_def with - | NodeAlias (profile_opt, {src=_;it= CallPreDef(ITERATOR_n(_,_,_))}) -> - finish_me "node alias with predef operator"; - assert false - - | NodeAlias (_, {src=_;it= CallPreDef(node)}) -> - assert false - (* - The only predef node that have static arg are array iterators. - - Raise a msg or is it catched before ? - *) - | NodeAlias ( - profile_opt, { src = lxm; it = CallUsrDef(idref, static_args) } - ) -> + | NodeAlias (profile_opt, { src = lxm; it = (idref, static_args) }) + -> let static_params = get_static_params_from_idref lxm idref in let static_eff = assert(List.length static_params = List.length static_args); diff --git a/src/parser.mly b/src/parser.mly index c4a38d56..dd1db24c 100644 --- a/src/parser.mly +++ b/src/parser.mly @@ -1140,8 +1140,6 @@ sxPredefOp: | TK_FBY { {src=$1; it=FBY_n} } | TK_PRE { {src=$1; it=PRE_n} } | TK_CURRENT{ {src=$1; it=CURRENT_n} } - | TK_INT { {src=$1; it=REAL2INT_n} } - | TK_REAL { {src=$1; it=INT2REAL_n} } | TK_ARROW { {src=$1; it=ARROW_n} } | TK_WHEN { {src=$1; it=WHEN_n} } | TK_AND { {src=$1; it=AND_n } } @@ -1180,14 +1178,17 @@ sxCallByPosExpression: sxEffectiveNode: /* Juste un nom */ sxIdentRef - { {src=$1.src; it=(CallUsrDef ($1.it, [])) } } + { {src=$1.src; it=(($1.it, [])) } } /* Un nom + des params statiques */ | sxIdentRef TK_OPEN_STATIC_PAR sxStaticArgList TK_CLOSE_STATIC_PAR - { {src=$1.src; it=(CallUsrDef ($1.it, List.rev $3)) } } - /* Un operateur prédéfini */ + { {src=$1.src; it=(($1.it, List.rev $3)) } } + /* Un operateur prédéfini | TK_OPERATOR sxPredefOp - { {src=$1; it=CallPreDef $2.it } } + { {src=$; it=($2.it, []) } } ; +XXX pour l'instant, j'enleve la possibilité d'avoir +(operator +(1,2)). On verra ca plus tard +*/ sxStaticArgList: sxStaticArg @@ -1239,9 +1240,12 @@ sxStaticArgList: sxSurelyNode: | sxIdentRef TK_OPEN_STATIC_PAR sxStaticArgList TK_CLOSE_STATIC_PAR - { {src=$1.src; it=(CallUsrDef ($1.it, List.rev $3)) } } - | TK_OPERATOR sxPredefOp - { {src=$2.src; it= (CallPreDef $2.it)} } + { {src=$1.src; it=($1.it, List.rev $3) } } +/* | TK_OPERATOR sxPredefOp + { {src=$2.src; it= ( $2.it)} } +XXX pour l'instant, j'enleve la possibilité d'avoir +(operator +(1,2)). On verra ca plus tard +*/ ; sxSurelyType: diff --git a/src/syntaxTreeCore.ml b/src/syntaxTreeCore.ml index 982e9f5f..4d06e7f6 100644 --- a/src/syntaxTreeCore.ml +++ b/src/syntaxTreeCore.ml @@ -1,4 +1,4 @@ -(** Time-stamp: <modified the 06/03/2008 (at 14:56) by Erwan Jahier> *) +(** Time-stamp: <modified the 06/03/2008 (at 16:10) by Erwan Jahier> *) (** (Raw) Abstract syntax tree of source programs. *) @@ -180,8 +180,7 @@ and by_name_op = (* for backward compatibility with lv4 *) and node_exp = - | CallPreDef of predef_node - | CallUsrDef of (Ident.idref * static_arg srcflagged list) + (Ident.idref * (static_arg srcflagged list)) (* Params statiques effectifs : - val_exp (pour les constantes) diff --git a/src/syntaxTreeDump.ml b/src/syntaxTreeDump.ml index 82570b2a..fa79ba54 100644 --- a/src/syntaxTreeDump.ml +++ b/src/syntaxTreeDump.ml @@ -1,4 +1,4 @@ -(** Time-stamp: <modified the 06/03/2008 (at 14:42) by Erwan Jahier> *) +(** Time-stamp: <modified the 06/03/2008 (at 15:14) by Erwan Jahier> *) open Lxm @@ -543,20 +543,14 @@ and dump_nary_exp and dump_node_exp (os : Format.formatter) - (n: node_exp) - = ( - match n with - CallPreDef op -> ( - fprintf os "operator %s" (op2string op) - ) | - (CallUsrDef (id, sal)) -> ( - fprintf os "%s" (Ident.string_of_idref id) ; - ( match sal with - [] -> () - | lst -> (fprintf os "<< @,%a@, >>" dump_static_arg_list lst) - ) - ) - ) + ((id, sal): node_exp) + = + fprintf os "%s" (Ident.string_of_idref id) ; + ( match sal with + [] -> () + | lst -> (fprintf os "<< @,%a@, >>" dump_static_arg_list lst) + ) + and dump_static_arg_list (os : Format.formatter) (lst: static_arg srcflagged list) diff --git a/src/test/should_work/Pascal/t.lus b/src/test/should_work/Pascal/t.lus index f69e73d9..40060ade 100644 --- a/src/test/should_work/Pascal/t.lus +++ b/src/test/should_work/Pascal/t.lus @@ -8,8 +8,8 @@ node toto ( x : bool) returns ( ); let a = A; - --b = B + A[0]; - b = operator +(B,A[0]); + b = B + A[0]; + --b = operator +(B,A[0]); tel node map2 diff --git a/src/test/should_work/Pascal/t1.lus b/src/test/should_work/Pascal/t1.lus index 2d308b21..9a1fa0e7 100644 --- a/src/test/should_work/Pascal/t1.lus +++ b/src/test/should_work/Pascal/t1.lus @@ -33,7 +33,7 @@ tel node bt_void<<const n: int>>(t : bool^n) returns (x : bool); let - x = fold<<operator or>>(false, t); + x = fold<<Lustre::or>>(false, t); tel (* devrait marcher ? *) diff --git a/src/test/should_work/Pascal/t2.lus b/src/test/should_work/Pascal/t2.lus index 246ea20f..3920f79e 100644 --- a/src/test/should_work/Pascal/t2.lus +++ b/src/test/should_work/Pascal/t2.lus @@ -39,16 +39,16 @@ tel -- Alors : node consensus_6(X : bool^6) returns (c : bool); let - c = fold_left << bool,bool,6, operator and >>(true, X); + c = fold_left << bool,bool,6, Lustre::and >>(true, X); tel -- Voire même : -node consensus_6_bis = fold_left << bool,bool,6, operator and >> ; +node consensus_6_bis = fold_left << bool,bool,6, Lustre::and >> ; -- Ou encore : node consensus_bis << const n : int >> = - fold_left << bool,bool,n, operator and >> ; + fold_left << bool,bool,n, Lustre::and >> ; diff --git a/src/test/test.res.exp b/src/test/test.res.exp index 0fd4cd27..faa9c98e 100644 --- a/src/test/test.res.exp +++ b/src/test/test.res.exp @@ -761,12 +761,9 @@ End of Syntax table dump. Exported constants: Exported nodes: ### skipping fold_left - node dummy::consensus_6_bis = dummy::fold_left<<type bool, type bool, const 6, operator and>>(bool, bool^6) returns (bool) on clock XXX - node dummy::consensus_6 = dummy::consensus_6(bool^6) returns (bool) on clock XXX - - ### skipping consensus_bis - ### skipping consensus +*** oops: an internal error occurred in file syntaxTab.ml, line 104, column 22 +*** when compiling lustre program should_work/Pascal/t2.lus *** SyntaxTab.create pass 1 *** SyntaxTab.create pass 2 init pack dummy -- GitLab