diff libinterp/parse-tree/lex.ll @ 27736:bd80e14f268a

improve parse error message for @()x+=expr (bug #57255) * oct-parse.yy (anon_fcn_begin): New utility non-terminal to set both m_parsing_anon_fcn and m_at_beginning_of_statement lexer feedback flags. (anon_fcn_handle): Use it instead of stmt_begin. Reset m_parsing_anon_fcn after parsing expression. * lex.h (lexical_feedback::m_parsing_anon_fcn): New flag. (lexical_feedback::lexical_feedback: Initialize it. (lexical_feedback::reset): Reset it. (base_lexer::handle_identifier): Don't recognize identifier as a command when parsing anonymous function body.
author John W. Eaton <jwe@octave.org>
date Fri, 22 Nov 2019 12:18:21 -0600
parents 5aad387784aa
children 16e83787f970
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll	Thu Nov 21 19:23:20 2019 -0600
+++ b/libinterp/parse-tree/lex.ll	Fri Nov 22 12:18:21 2019 -0600
@@ -2156,6 +2156,7 @@
     m_looking_at_matrix_or_assign_lhs = false;
     m_looking_for_object_index = false;
     m_looking_at_indirect_ref = false;
+    m_parsing_anon_fcn_body = false;
     m_parsing_class_method = false;
     m_parsing_classdef = false;
     m_parsing_classdef_decl = false;
@@ -3170,12 +3171,13 @@
     // function call with the argument "+1".
 
     if (m_at_beginning_of_statement
-        && (! (is_variable (ident, scope)
-               || ident == "e" || ident == "pi"
-               || ident == "I" || ident == "i"
-               || ident == "J" || ident == "j"
-               || ident == "Inf" || ident == "inf"
-               || ident == "NaN" || ident == "nan")))
+        && ! (m_parsing_anon_fcn_body
+              || is_variable (ident, scope)
+              || ident == "e" || ident == "pi"
+              || ident == "I" || ident == "i"
+              || ident == "J" || ident == "j"
+              || ident == "Inf" || ident == "inf"
+              || ident == "NaN" || ident == "nan"))
       tok->mark_may_be_command ();
 
     push_token (tok);