Mercurial > hg > octave-lyh
diff libinterp/parse-tree/lex.ll @ 16788:f89de736eecd
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.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jun 2013 18:21:48 -0400 |
parents | 0bf1d559b321 |
children | 498b2dd1bd56 531473481084 |
line wrap: on
line diff
--- 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"