Mercurial > octave
diff libinterp/parse-tree/oct-parse.yy @ 28147:648202bebcb0 stable
improve treatment of comments at interactive command line (bug #57924)
* lex.ll (HANDLE_EOB_OR_EOF): New macro.
(HANDLE_STRING_CONTINUATION,
<BLOCK_COMMENT_START>^{S}*{CCHAR}\{{S}*{NL},
<BLOCK_COMMENT_START>^{S}*{CCHAR}\}{S}*{NL},
<BLOCK_COMMENT_START>{ANY_EXCEPT_NL}*{NL},
<LINE_COMMENT_START>{ANY_INCLUDING_NL}):
Use HANDLE_EOB_OR_EOF to signal that we parsed a comment or need more
input when using the push lexer interface.
* oct-parse.yy (push_parser::run): Handle token value of -2 returned
from the lexer to indicate that a comment was recognized.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 09 Mar 2020 10:24:07 -0400 |
parents | 9e983eb1749d |
children | a04cb1364af4 026bff6a54d7 |
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.yy Sun Mar 08 17:49:43 2020 -0400 +++ b/libinterp/parse-tree/oct-parse.yy Mon Mar 09 10:24:07 2020 -0400 @@ -4661,7 +4661,12 @@ if (token < 0) { - status = -1; + // TOKEN == -2 means that the lexer recognized a comment + // and we should be at the end of the buffer but not the + // end of the file so we should return 0 to indicate + // "complete input" instead of -1 to request more input. + + status = (token == -2 ? 0 : -1); if (! eof && m_lexer.at_end_of_buffer ()) return status;