diff libinterp/parse-tree/pt-idx.h @ 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 fff643eb3514
children fcaecdbc8d8a
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-idx.h	Mon Jan 28 18:01:46 2019 +0000
+++ b/libinterp/parse-tree/pt-idx.h	Thu Jan 31 18:45:37 2019 +0000
@@ -89,6 +89,10 @@
 
     std::list<tree_expression *> dyn_fields (void) { return m_dyn_field; }
 
+    void mark_word_list_cmd (void) { m_word_list_cmd = true; }
+
+    bool is_word_list_cmd (void) const { return m_word_list_cmd; }
+
     bool lvalue_ok (void) const { return m_expr->lvalue_ok (); }
 
     bool rvalue_ok (void) const { return true; }
@@ -125,6 +129,9 @@
     // The list of dynamic field names, if any.
     std::list<tree_expression *> m_dyn_field;
 
+    // TRUE if this expression was parsed as a word list command.
+    bool m_word_list_cmd;
+
     tree_index_expression (int l, int c);
 
     octave_map make_arg_struct (void) const;