Mercurial > hg > octave-lyh
diff libinterp/parse-tree/pt-mat.cc @ 16924:aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
* oct-parse.in.yy (matrix_rows1, cell_rows1): Delete non-terminals.
(matrix, matrix_rows, cell, cell_rows): Ignore empty elements.
(cell_or_matrix_row): Handle leading and trailing commas.
(octave_base_parser::finish_matrix, octave_base_parser::finish_cell):
Handle null matrix and cell objects.
* pt-mat.cc: New tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 08 Jul 2013 12:20:04 -0400 |
parents | 70f465930546 |
children | bc924baa2c4e |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-mat.cc +++ b/libinterp/parse-tree/pt-mat.cc @@ -1336,6 +1336,34 @@ %!assert (class ([cell(1), struct("foo", "bar")]), "cell") %!error [struct("foo", "bar"), cell(1)] + +%!assert ([,1], 1) +%!assert ([1,], 1) +%!assert ([,1,], 1) +%!assert ([,1,;;], 1) +%!assert ([,1,;,;], 1) + +%!assert ([1,1], ones (1, 2)) +%!assert ([,1,1], ones (1, 2)) +%!assert ([1,1,], ones (1, 2)) +%!assert ([,1,1,], ones (1, 2)) +%!assert ([,1,1,;;], ones (1, 2)) +%!assert ([,1,1,;,;], ones (1, 2)) +%!assert ([,;,1,1], ones (1, 2)) + +%!assert ([1;1], ones (2, 1)) +%!assert ([1,;1], ones (2, 1)) +%!assert ([1,;,;1], ones (2, 1)) + +%!error eval ("[,,]") +%!error eval ("[,,;,]") +%!error eval ("[,;,,;,]") + +%!assert (isnull ([,])) +%!assert (isnull ([;])) +%!assert (isnull ([;;])) +%!assert (isnull ([;,;])) +%!assert (isnull ([,;,;,])) */ DEFUN (string_fill_char, args, nargout,