From 2bd6282aef45f633a0fc527fc54388c36cbf20c5 Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Tue, 25 Jun 2019 12:13:45 +0200 Subject: [PATCH] Revert "macro processor: support array comprehension" (should not have been pushed yet) This reverts commit f2c93d377f5f1861263b3519639e3c0ad34dcca3. --- src/macro/Expressions.cc | 32 -------------------------------- src/macro/Expressions.hh | 25 ------------------------- src/macro/Parser.yy | 4 ---- 3 files changed, 61 deletions(-) diff --git a/src/macro/Expressions.cc b/src/macro/Expressions.cc index b0685d12..7e2de2a8 100644 --- a/src/macro/Expressions.cc +++ b/src/macro/Expressions.cc @@ -943,12 +943,6 @@ Comprehension::eval() return make_shared<Array>(values, env); } -BaseTypePtr -ArrayComprehension::eval() -{ - return make_shared<Double>(1, env); -} - string Array::to_string() const noexcept { @@ -1118,15 +1112,6 @@ TrinaryOp::to_string() const noexcept exit(EXIT_FAILURE); } -string -ArrayComprehension::to_string() const noexcept -{ - string retval = "[" + c_expr->to_string() + " for " + c_vars->to_string() + " in " + c_set->to_string(); - if (c_when) - retval += " when " + c_when->to_string(); - return retval + "]"; -} - void String::print(ostream &output, bool matlab_output) const noexcept { @@ -1394,20 +1379,3 @@ Comprehension::print(ostream &output, bool matlab_output) const noexcept output << "]"; } -void -ArrayComprehension::print(ostream &output, bool matlab_output) const noexcept -{ - output << "["; - c_expr->print(output, matlab_output); - output << " for "; - c_vars->print(output, matlab_output); - output << " in "; - c_set->print(output, matlab_output); - if (c_when) - { - output << " when "; - c_when->print(output, matlab_output); - } - output << "]"; -} - diff --git a/src/macro/Expressions.hh b/src/macro/Expressions.hh index ebf5332b..0600e9d5 100644 --- a/src/macro/Expressions.hh +++ b/src/macro/Expressions.hh @@ -470,30 +470,5 @@ namespace macro void print(ostream &output, bool matlab_output = false) const noexcept override; BaseTypePtr eval() override; }; - - - class ArrayComprehension final : public Expression - { - private: - const ExpressionPtr c_expr, c_vars, c_set, c_when; - public: - ArrayComprehension(const ExpressionPtr c_expr_arg, - const ExpressionPtr c_vars_arg, - const ExpressionPtr c_set_arg, - const ExpressionPtr c_when_arg, - Environment &env_arg, const Tokenizer::location location_arg) : - Expression(env_arg, move(location_arg)), - c_expr{move(c_expr_arg)}, c_vars{move(c_vars_arg)}, - c_set{move(c_set_arg)}, c_when{move(c_when_arg)} { } - ArrayComprehension(const ExpressionPtr c_expr_arg, - const ExpressionPtr c_vars_arg, - const ExpressionPtr c_set_arg, - Environment &env_arg, const Tokenizer::location location_arg) : - Expression(env_arg, move(location_arg)), - c_expr{move(c_expr_arg)}, c_vars{move(c_vars_arg)}, c_set{move(c_set_arg)} { } - string to_string() const noexcept override; - void print(ostream &output, bool matlab_output = false) const noexcept override; - BaseTypePtr eval() override; - }; } #endif diff --git a/src/macro/Parser.yy b/src/macro/Parser.yy index 3c0060a1..85972412 100644 --- a/src/macro/Parser.yy +++ b/src/macro/Parser.yy @@ -305,10 +305,6 @@ expr : LPAREN expr RPAREN { $$ = make_shared<Tuple>($2, driver.env, @$); } | LBRACKET expr IN expr WHEN expr RBRACKET { $$ = make_shared<Comprehension>($2, $4, $6, driver.env, @$); } - | LBRACKET expr FOR expr IN expr RBRACKET - { $$ = make_shared<ArrayComprehension>($2, $4, $6, driver.env, @$); } - | LBRACKET expr FOR expr IN expr WHEN expr RBRACKET - { $$ = make_shared<ArrayComprehension>($2, $4, $6, $8, driver.env, @$); } | NOT expr { $$ = make_shared<UnaryOp>(codes::UnaryOp::logical_not, $2, driver.env, @$); } | MINUS expr %prec UMINUS -- GitLab