changeset 31464:344e1152ed88

remove operators deprecated in version 7 * lex.h, lex.ll (base_lexer::warn_deprecated_operator): Delete. (CMD_OR_DEPRECATED_OP): Delete. (".+", ".+=", ".-", ".-=", "**", "**=", ".**", ".**="): Delete patterns for obsolete operators. * pt-eval.cc: Update test. (get_operator_function_name): Remove support for obsolete operators. * NEWS.9.md: Note change.
author John W. Eaton <jwe@octave.org>
date Thu, 17 Nov 2022 11:50:20 -0500
parents 6ea81caebab0
children c09bd3c7905b
files etc/NEWS.9.md libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll libinterp/parse-tree/pt-eval.cc
diffstat 4 files changed, 15 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/etc/NEWS.9.md	Wed Nov 16 16:13:30 2022 -0800
+++ b/etc/NEWS.9.md	Thu Nov 17 11:50:20 2022 -0500
@@ -41,6 +41,19 @@
         disable_permutation_matrix | optimize_permutation_matrix
         disable_range              | optimize_range
 
+- Operators
+
+        Operator | Replacement
+        ---------|------------
+        .+       | +
+        .+=      | +=
+        .-       | -
+        .-=      | -=
+        **       | ^
+        **=      | ^=
+        .**      | .^
+        .**=     | .^=
+
 - For plot functions, the use of numbers to select line colors in
   shorthand formats was an undocumented feature was removed from Octave 9.
 
--- a/libinterp/parse-tree/lex.h	Wed Nov 16 16:13:30 2022 -0800
+++ b/libinterp/parse-tree/lex.h	Thu Nov 17 11:50:20 2022 -0500
@@ -693,10 +693,6 @@
 
     void warn_deprecated_syntax (const std::string& msg);
 
-    void warn_deprecated_operator (const std::string& deprecated_op,
-                                   const std::string& recommended_op,
-                                   const std::string& version);
-
     void push_token (token *);
 
     token * current_token (void);
--- a/libinterp/parse-tree/lex.ll	Wed Nov 16 16:13:30 2022 -0800
+++ b/libinterp/parse-tree/lex.ll	Thu Nov 17 11:50:20 2022 -0500
@@ -183,28 +183,6 @@
      }                                                                  \
    while (0)
 
-#define CMD_OR_DEPRECATED_OP(PATTERN, REPLACEMENT, VERSION, TOK)        \
-   do                                                                   \
-     {                                                                  \
-       curr_lexer->lexer_debug (PATTERN);                               \
-                                                                        \
-       if (curr_lexer->looks_like_command_arg ())                       \
-         {                                                              \
-           yyless (0);                                                  \
-           curr_lexer->push_start_state (COMMAND_START);                \
-         }                                                              \
-       else                                                             \
-         {                                                              \
-           curr_lexer->warn_deprecated_operator (PATTERN, REPLACEMENT,  \
-                                                 #VERSION);             \
-           /* set COMPAT to true here to avoid warning about            \
-              compatibility since we've already warned about the        \
-              operator being deprecated.  */                            \
-           return curr_lexer->handle_op (TOK, false, true);             \
-         }                                                              \
-     }                                                                  \
-   while (0)
-
 #define CMD_OR_UNARY_OP(PATTERN, TOK, COMPAT)                           \
    do                                                                   \
      {                                                                  \
@@ -1644,13 +1622,10 @@
 %}
 
 ":"   { CMD_OR_OP (":", ':', true); }
-".+"  { CMD_OR_DEPRECATED_OP (".+", "+", 7, '+'); }
-".-"  { CMD_OR_DEPRECATED_OP (".-", "-", 7, '-'); }
 ".*"  { CMD_OR_OP (".*", EMUL, true); }
 "./"  { CMD_OR_OP ("./", EDIV, true); }
 ".\\" { CMD_OR_OP (".\\", ELEFTDIV, true); }
 ".^"  { CMD_OR_OP (".^", EPOW, true); }
-".**" { CMD_OR_DEPRECATED_OP (".**", ".^", 7, EPOW); }
 "<="  { CMD_OR_OP ("<=", EXPR_LE, true); }
 "=="  { CMD_OR_OP ("==", EXPR_EQ, true); }
 "!="  { CMD_OR_OP ("!=", EXPR_NE, false); }
@@ -1680,7 +1655,6 @@
   }
 
 "^"   { CMD_OR_OP ("^", POW, true); }
-"**"  { CMD_OR_DEPRECATED_OP ("**", "^", 7, POW); }
 "&&"  { CMD_OR_OP ("&&", EXPR_AND_AND, true); }
 "||"  { CMD_OR_OP ("||", EXPR_OR_OR, true); }
 
@@ -1817,15 +1791,11 @@
 "*="   { CMD_OR_OP ("*=", MUL_EQ, false); }
 "/="   { CMD_OR_OP ("/=", DIV_EQ, false); }
 "\\="  { CMD_OR_OP ("\\=", LEFTDIV_EQ, false); }
-".+="  { CMD_OR_DEPRECATED_OP (".+=", "+=", 7, ADD_EQ); }
-".-="  { CMD_OR_DEPRECATED_OP (".-=", "-=", 7, SUB_EQ); }
 ".*="  { CMD_OR_OP (".*=", EMUL_EQ, false); }
 "./="  { CMD_OR_OP ("./=", EDIV_EQ, false); }
 ".\\=" { CMD_OR_OP (".\\=", ELEFTDIV_EQ, false); }
 "^="   { CMD_OR_OP ("^=", POW_EQ, false); }
-"**="  { CMD_OR_DEPRECATED_OP ("**=", "^=", 7, POW_EQ); }
 ".^="  { CMD_OR_OP (".^=", EPOW_EQ, false); }
-".**=" { CMD_OR_DEPRECATED_OP (".**=", ".^=", 7, EPOW_EQ); }
 "&="   { CMD_OR_OP ("&=", AND_EQ, false); }
 "|="   { CMD_OR_OP ("|=", OR_EQ, false); }
 
@@ -3682,16 +3652,6 @@
   }
 
   void
-  base_lexer::warn_deprecated_operator (const std::string& deprecated_op,
-                                        const std::string& recommended_op,
-                                        const std::string& version)
-  {
-    std::string msg = "the '" + deprecated_op + "' operator was deprecated in version " + version + " and will not be allowed in a future version of Octave; please use '" + recommended_op + "' instead";
-
-    warn_deprecated_syntax (msg);
-  }
-
-  void
   base_lexer::push_token (token *tok)
   {
     YYSTYPE *lval = yyget_lval (m_scanner);
--- a/libinterp/parse-tree/pt-eval.cc	Wed Nov 16 16:13:30 2022 -0800
+++ b/libinterp/parse-tree/pt-eval.cc	Thu Nov 17 11:50:20 2022 -0500
@@ -1483,15 +1483,9 @@
     // the corresponding function name.  At least try to do it without N
     // string compares.
 
-    // FIXME: .+, .-, **, and .** are deprecated but still need to be
-    // handled here until they are removed.
-
     std::size_t len = name.length ();
 
-    if (len == 3 && name == ".**")
-      // deprecated
-      return "power";
-    else if (len == 2)
+    if (len == 2)
       {
         if (name[0] == '.')
           {
@@ -1500,14 +1494,6 @@
               case '\'':
                 return "transpose";
 
-              case '+':
-                // deprecated
-                return "plus";
-
-              case '-':
-                // deprecated
-                return "minus";
-
               case '*':
                 return "times";
 
@@ -1545,9 +1531,6 @@
                 break;
               }
           }
-        else if (name == "**")
-          // deprecated
-          return "mpower";
       }
     else if (len == 1)
       {
@@ -1820,10 +1803,7 @@
 
 /*
 %!test
-%! x = {".**", "power";
-%!      ".'", "transpose";
-%!      ".+", "plus";
-%!      ".-", "minus";
+%! x = {".'", "transpose";
 %!      ".*", "times";
 %!      "./", "rdivide";
 %!      ".^", "power";
@@ -1833,7 +1813,6 @@
 %!      ">=", "ge";
 %!      "!=", "ne";
 %!      "~=", "ne";
-%!      "**", "mpower";
 %!      "~", "not";
 %!      "!", "not";
 %!      "\'", "ctranspose";