# HG changeset patch # User John W. Eaton # Date 1371766908 14400 # Node ID f89de736eecdaf37082354daa07804c85baf259e # Parent 2cfd8cd9e1b6869d6e706b725104d64ddaa914c4 correctly parse expressions like pi+1 (bug #39301) * lex.ll (CMD_OR_UNARY_OP): Also check whether the current token looks like a command argument. (octave_base_lexer::handle_identifier): Special treatment for pi. diff --git a/libinterp/parse-tree/lex.ll b/libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -173,8 +173,15 @@ \ if (curr_lexer->previous_token_may_be_command ()) \ { \ - yyless (0); \ - curr_lexer->push_start_state (COMMAND_START); \ + if (curr_lexer->looks_like_command_arg ()) \ + { \ + yyless (0); \ + curr_lexer->push_start_state (COMMAND_START); \ + } \ + else \ + { \ + return curr_lexer->handle_op_internal (TOK, false, COMPAT); \ + } \ } \ else \ { \ @@ -2652,9 +2659,16 @@ token *tok_val = new token (NAME, &(symbol_table::insert (tok, sid)), input_line_number, current_input_column); + // The following symbols are handled specially so that things like + // + // pi +1 + // + // are parsed as an addition expression instead of as a command-style + // function call with the argument "+1". + if (at_beginning_of_statement && (! (is_variable (tok) - || tok == "e" + || tok == "e" || tok == "pi" || tok == "I" || tok == "i" || tok == "J" || tok == "j" || tok == "Inf" || tok == "inf"