Mercurial > octave-nkf
changeset 16144:8f1f8a5cdc96
maint: Merge in Jaane's changes
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Wed, 27 Feb 2013 15:58:06 -0500 |
parents | 752a5de459c2 (current diff) 26d65d677557 (diff) |
children | edddf8903f15 |
files | |
diffstat | 5 files changed, 43 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/contributors.in Wed Feb 27 21:31:55 2013 +0200 +++ b/doc/interpreter/contributors.in Wed Feb 27 15:58:06 2013 -0500 @@ -10,6 +10,7 @@ Alexander Barth David Bateman Heinz Bauschke +Julien Bect Roman Belov Karl Berry David Billinghurst
--- a/libinterp/parse-tree/oct-parse.yy Wed Feb 27 21:31:55 2013 +0200 +++ b/libinterp/parse-tree/oct-parse.yy Wed Feb 27 15:58:06 2013 -0500 @@ -155,9 +155,7 @@ // Forward declarations for some functions defined at the bottom of // the file. -// Generic error messages. -static void -yyerror (const char *s); +static void yyerror (const char *s); // Finish building a statement. template <class T> @@ -1042,7 +1040,7 @@ primary_fcn_scope = symbol_table::current_scope (); if (reading_script_file && current_function_depth > 1) - yyerror ("nested functions not implemented in this context"); + curr_parser->bison_error ("nested functions not implemented in this context"); } ; @@ -1078,7 +1076,7 @@ } | param_list_beg error { - yyerror ("invalid parameter list"); + curr_parser->bison_error ("invalid parameter list"); $$ = 0; ABORT_PARSE; } @@ -1248,13 +1246,13 @@ // A lot of tests are based on the assumption that this is OK // if (reading_script_file) // { -// yyerror ("function body open at end of script"); +// curr_parser->bison_error ("function body open at end of script"); // YYABORT; // } if (endfunction_found) { - yyerror ("inconsistent function endings -- " + curr_parser->bison_error ("inconsistent function endings -- " "if one function is explicitly ended, " "so must all the others"); YYABORT; @@ -1263,13 +1261,13 @@ if (! (reading_fcn_file || reading_script_file || get_input_from_eval_string)) { - yyerror ("function body open at end of input"); + curr_parser->bison_error ("function body open at end of input"); YYABORT; } if (reading_classdef_file) { - yyerror ("classdef body open at end of input"); + curr_parser->bison_error ("classdef body open at end of input"); YYABORT; } @@ -1445,7 +1443,7 @@ ; parse_error : LEXICAL_ERROR - { yyerror ("parse error"); } + { curr_parser->bison_error ("parse error"); } | error ; @@ -1498,6 +1496,12 @@ static void yyerror (const char *s) { + curr_parser->bison_error (s); +} + +void +octave_parser::bison_error (const char *s) +{ int err_col = curr_lexer->current_input_column - 1; std::ostringstream output_buf; @@ -1612,7 +1616,7 @@ { retval = false; - yyerror ("parse error"); + bison_error ("parse error"); int l = tok->line (); int c = tok->column (); @@ -2324,7 +2328,7 @@ else { if (parfor) - yyerror ("invalid syntax for parfor statement"); + bison_error ("invalid syntax for parfor statement"); else retval = new tree_complex_for_command (lhs, expr, body, lc, tc, l, c); @@ -2578,7 +2582,7 @@ else if (t == octave_value::op_asn_eq) return new tree_multi_assignment (lhs, rhs, false, l, c); else - yyerror ("computed multiple assignment not allowed"); + bison_error ("computed multiple assignment not allowed"); return retval; } @@ -2857,7 +2861,7 @@ if (args && args->has_magic_tilde ()) { - yyerror ("invalid use of empty argument (~) in index expression"); + bison_error ("invalid use of empty argument (~) in index expression"); return retval; } @@ -2975,7 +2979,7 @@ octave_parser::validate_matrix_row (tree_argument_list *row) { if (row && row->has_magic_tilde ()) - yyerror ("invalid use of tilde (~) in matrix expression"); + bison_error ("invalid use of tilde (~) in matrix expression"); return row; }
--- a/libinterp/parse-tree/parse.h Wed Feb 27 21:31:55 2013 +0200 +++ b/libinterp/parse-tree/parse.h Wed Feb 27 15:58:06 2013 -0500 @@ -326,6 +326,9 @@ append_statement_list (tree_statement_list *list, char sep, tree_statement *stmt, bool warn_missing_semi); + // Generic error messages. + void bison_error (const char *s); + // TRUE means that we have encountered EOF on the input stream. bool end_of_input;
--- a/libinterp/parse-tree/pt-mat.cc Wed Feb 27 21:31:55 2013 +0200 +++ b/libinterp/parse-tree/pt-mat.cc Wed Feb 27 15:58:06 2013 -0500 @@ -402,7 +402,7 @@ first_elem = false; dv = this_elt_dv; } - else if (! dv.hvcat (this_elt_dv, 1)) + else if ((! any_class) && (! dv.hvcat (this_elt_dv, 1))) { eval_error ("horizontal dimensions mismatch", dv, this_elt_dv); break; @@ -644,7 +644,7 @@ dv(1) = this_elt_nc; dv(0) += this_elt_nr; } - else if (! dv.hvcat (this_elt_dv, 0)) + else if ((!any_class) && (!dv.hvcat (this_elt_dv, 0))) { eval_error ("vertical dimensions mismatch", dv, this_elt_dv); return;
--- a/test/classes/classes.tst Wed Feb 27 21:31:55 2013 +0200 +++ b/test/classes/classes.tst Wed Feb 27 15:58:06 2013 -0500 @@ -304,6 +304,10 @@ %!assert (s1 >= (x1 - 1)) %!assert (x1 >= (s1 - 1)) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Testing horizontal & vertical concatenation %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %% Test overloaded vertcat() for the Snork class %% See bug #38170 (http://savannah.gnu.org/bugs/?38170) %!test s = [s1; s2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1; x2])); @@ -316,6 +320,20 @@ %!xtest s = [s1 x2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1 x2])); %!xtest s = [x1 s2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1 x2])); +%% Test with the Blork class, where neither vertcat() nor horzcat() is overloaded +%!shared x1, x2, x3 +%!test x1 = Blork(); +%!test x2 = [x1 x1]; +%!assert (isa (x2, 'Blork') && isequal (size (x2), [1 2])); +%!test x2 = [x1 51]; +%!assert (isa (x2, 'Blork') && isequal (size (x2), [1 2])); +%!test x3 = [x2; x2]; +%!assert (isa (x3, 'Blork') && isequal (size (x3), [2 2])); +%!test x3 = [x2; [51 x1]]; +%!assert (isa (x3, 'Blork') && isequal (size (x3), [2 2])); +%!error <dimension mismatch> x4 = [x1 x3]; +%!error <dimension mismatch> x4 = [x1; x3]; + %%%%%%%%%%%%%%%%%%%%%%%% %% Testing precedence %% %%%%%%%%%%%%%%%%%%%%%%%%