changeset 33320:57b178bf32dd

new function to create word list command * parse.h, oct-parse.yy (base_parser::make_word_list_command): New function. (word_list_cmd): Use it instead of make_index_expression.
author John W. Eaton <jwe@octave.org>
date Thu, 04 Apr 2024 15:01:56 -0400
parents b794f004bff7
children 44c24e645677
files libinterp/parse-tree/oct-parse.yy libinterp/parse-tree/parse.h
diffstat 2 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.yy	Thu Apr 04 14:16:38 2024 -0400
+++ b/libinterp/parse-tree/oct-parse.yy	Thu Apr 04 15:01:56 2024 -0400
@@ -511,13 +511,11 @@
 
 word_list_cmd   : identifier word_list
                   {
-                    if (! ($$ = parser.make_index_expression ($1, nullptr, $2, nullptr, '(')))
+                    if (! ($$ = parser.make_word_list_command ($1, $2)))
                       {
                         // make_index_expression deleted $1 and $2.
                         YYABORT;
                       }
-
-                    $$->mark_word_list_cmd ();
                   }
                 ;
 
@@ -4418,6 +4416,18 @@
     return true;
   }
 
+  // Make a word list command.
+  tree_index_expression *
+  base_parser::make_word_list_command (tree_expression *expr, tree_argument_list *args)
+  {
+    tree_index_expression *retval = make_index_expression (expr, nullptr, args, nullptr, '(');
+
+    if (retval)
+      retval->mark_word_list_cmd ();
+
+    return retval;
+  }
+
   // Make an index expression.
 
   tree_index_expression *
--- a/libinterp/parse-tree/parse.h	Thu Apr 04 14:16:38 2024 -0400
+++ b/libinterp/parse-tree/parse.h	Thu Apr 04 15:01:56 2024 -0400
@@ -519,6 +519,10 @@
   OCTINTERP_API bool
   finish_classdef_file (tree_classdef *cls, tree_statement_list *local_fcns, token *eof_tok);
 
+  // Make a word list command.
+  OCTINTERP_API tree_index_expression *
+  make_word_list_command (tree_expression *expr, tree_argument_list *args);
+
   // Make an index expression.
   OCTINTERP_API tree_index_expression *
   make_index_expression (tree_expression *expr, token *open_paren, tree_argument_list *args, token *close_paren, char type);