Mercurial > octave
changeset 28772:20b4bd415083 stable
avoid parse error with continuation in matrix list (bug #59150)
* lex.ll (<MATRIX_START>\.\.\.{ANY_EXCEPT_NL}*{NL}): New pattern to
handle continuation lines specially inside matrix lists.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 22 Sep 2020 09:29:36 -0400 |
parents | 61788482bcb7 |
children | 9cd5d348d36c |
files | libinterp/parse-tree/lex.ll |
diffstat | 1 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll Tue Sep 22 19:25:26 2020 +0200 +++ b/libinterp/parse-tree/lex.ll Tue Sep 22 09:29:36 2020 -0400 @@ -526,6 +526,10 @@ curr_lexer->m_filepos.increment_column (yyleng); } +%{ +// Whitespace inside matrix lists. +%} + <MATRIX_START>{S}* { curr_lexer->lexer_debug ("<MATRIX_START>{S}*"); @@ -551,6 +555,24 @@ } %{ +// Continuation lines in matrix constants are handled as whitespace. +// Allow arbitrary text after the continuation marker. +%} + +<MATRIX_START>\.\.\.{ANY_EXCEPT_NL}*{NL} { + curr_lexer->lexer_debug ("<MATRIX_START>\\.\\.\\.{ANY_EXCEPT_NL}*{NL}"); + + curr_lexer->handle_continuation (); + + // Even if there wasn't a space before or after the continuation + // marker, treat the continuation as if it were. But since it will + // be transformed to a separator later anyway, there's no need to + // actually unput a space on the input stream. + + curr_lexer->mark_previous_token_trailing_space (); + } + +%{ // For this and the next two rules, we're looking at ']', and we // need to know if the next token is '=' or '=='. //