Mercurial > octave
view src/octave-build-info.h @ 29900:da6e5914ddaf
handle all binary operators the same when detecting command syntax (bug #60882)
This change breaks Matlab compatibility when parsing things like
x += 2
Matlab will handle this as a command-style function call with two
arguments '+=' and '2'. Octave will now treat this as a computed
assignment (the variable X incremented by 2). Octave will still
handle
x +=2
as a command-style function call when parsing this statement inside a
function.
At the command line, Octave will recognize this statement as a
computed assignment expression if X is already defined to be a
variable. Note that command lines are parsed completely before
executing anything, so in
octave> clear x
octave> x = 1; x +=2
the "x +=2" statement will be parsed as a command-style function call
because the parser does not find a definition for X as a variable when
that portion of the command line is parsed.
* lex.ll (CMD_OR_COMPUTED_ASSIGN_OP): Delete macro. Change all uses
to CMD_OR_OP instead.
(base_lexer::handle_identifier): Don't call mark_may_be_command for
token if we are at the top level and the identifier has already been
recognized as a variable.
* parser.tst: Update test.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 21 Jul 2021 09:49:09 -0400 |
parents | 0a5b15007766 |
children | 796f54d4ddbf |
line wrap: on
line source
//////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016-2021 The Octave Project Developers // // See the file COPYRIGHT.md in the top-level directory of this // distribution or <https://octave.org/copyright/>. // // This file is part of Octave. // // Octave is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Octave is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Octave; see the file COPYING. If not, see // <https://www.gnu.org/licenses/>. // //////////////////////////////////////////////////////////////////////// #if ! defined (octave_octave_build_info_h) #define octave_octave_build_info_h 1 #include "octave-config.h" #include <ctime> #include <string> extern std::string octave_hg_id (void); #endif