diff libinterp/parse-tree/oct-parse.yy @ 26662:05fc703b419a

update handling of command-style function call syntax in eval * lex.h, lex.ll (lexical_feedback::m_allow_command_syntax): New data member. (lexical_feedback::reset): Reset it. (lexical_feedback::previous_token_may_be_command, base_lexer::looks_like_command_arg): Return false immediately if m_allow_command_syntax is false. (base_lexer::is_variable): Check if name is a variable if parsing in top level scope. * parse.h, oct-parse.yy (base_parser::disallow_command_syntax): New function. (word_list_command): Mark index expression as a word list command. * pt-eval.cc (tree_evaluator::eval_string): If nargout > 0, don't allow evaluated code to be parsed as a command-style function call. (tree_evaluator::visit_index_expression): Error if identifier is a variable and index expression is a command-style function call. * pt-idx.h, pt-idx.cc (tree_index_expression::m_word_list_cmd): New member variable. (tree_index_expression::mark_word_list_cmd, tree_index_expression::is_word_list_cmd): New functions. * clearvars.m: Avoid evaluating command-style function call when assigning result of call to eval. * test/eval-command.tst: New file. * bug-38565.tst, bug-38576.tst: Delete obsolete tests. * test/module.mk: Update.
author John W. Eaton <jwe@octave.org>
date Thu, 31 Jan 2019 18:45:37 +0000
parents cf9e10ce3351
children 581d01526b34
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.yy	Mon Jan 28 18:01:46 2019 +0000
+++ b/libinterp/parse-tree/oct-parse.yy	Thu Jan 31 18:45:37 2019 +0000
@@ -484,6 +484,7 @@
                         // make_index_expression deleted $1 and $2.
                         YYABORT;
                       }
+                    $$->mark_word_list_cmd ();
                   }
                 ;
 
@@ -4314,6 +4315,12 @@
   }
 
   void
+  base_parser::disallow_command_syntax (void)
+  {
+    m_lexer.m_allow_command_syntax = false;
+  }
+
+  void
   base_parser::bison_error (const std::string& str, int l, int c)
   {
     int err_line = l < 0 ? m_lexer.m_input_line_number : l;