# HG changeset patch # User John W. Eaton # Date 1627055980 14400 # Node ID 28a39ddabbfca26215cf9b58b28f89e943d2efc0 # Parent daf351544539cca4d51916d5bcbbe0b819dcd50e allow unrecognized characters to begin command-style function call parsing * lex.ll (.): Instead of always producing a lexical error, allow an otherwise unrecognized character to trigger command-style function call parsing if the previous token may be a token and is followed by a space. diff -r daf351544539 -r 28a39ddabbfc libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Fri Jul 23 09:26:35 2021 +0200 +++ b/libinterp/parse-tree/lex.ll Fri Jul 23 11:59:40 2021 -0400 @@ -1880,40 +1880,52 @@ } %{ -// Unrecognized input is a lexical error. +// Unrecognized input. If the previous token may be a command and is +// followed by a space, parse the remainder of this statement as a +// command-style function call. Otherwise, unrecognized input is a +// lexical error. %} . { curr_lexer->lexer_debug ("."); - curr_lexer->xunput (yytext[0]); - - int c = curr_lexer->text_yyinput (); - - if (c == 1) - return -1; - else if (c == EOF) - return curr_lexer->handle_end_of_input (); + if (curr_lexer->previous_token_may_be_command () + && curr_lexer->space_follows_previous_token ()) + { + yyless (0); + curr_lexer->push_start_state (COMMAND_START); + } else { - std::ostringstream buf; - - buf << "invalid character '" - << octave::undo_string_escape (static_cast (c)) - << "' (ASCII " << c << ")"; - - // Use current file position for error token. - octave::token *tok - = new octave::token (LEXICAL_ERROR, buf.str (), - curr_lexer->m_filepos, curr_lexer->m_filepos); - - curr_lexer->push_token (tok); - - curr_lexer->m_filepos.increment_column (); - - return curr_lexer->count_token_internal (LEXICAL_ERROR); + curr_lexer->xunput (yytext[0]); + + int c = curr_lexer->text_yyinput (); + + if (c == 1) + return -1; + else if (c == EOF) + return curr_lexer->handle_end_of_input (); + else + { + std::ostringstream buf; + + buf << "invalid character '" + << octave::undo_string_escape (static_cast (c)) + << "' (ASCII " << c << ")"; + + // Use current file position for error token. + octave::token *tok + = new octave::token (LEXICAL_ERROR, buf.str (), + curr_lexer->m_filepos, curr_lexer->m_filepos); + + curr_lexer->push_token (tok); + + curr_lexer->m_filepos.increment_column (); + + return curr_lexer->count_token_internal (LEXICAL_ERROR); + } } - } +} %{ #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)