Mercurial > octave
diff libinterp/parse-tree/pt-pr-code.cc @ 23600:db947ba52118
explicitly limit anonymous functions to a single expression
* ov-fcn-handle.cc (octave_fcn_handle::print_raw): Handle anonymous
function body as a single expression.
* parse.h, oct-parse.in.yy: Now expect 8 shift/reduce conflicts.
(expr_no_assign): New non-terminal.
(expression): Split into expr_no_assign and assign_expr.
(anon_fcn_handle): Define body as expr_no_assign instead of statement.
(base_parser::make_anon_fcn_handle): Handle body as a single
expression instead of statement.
* pt-eval.cc (tree_evaluator::visit_anon_fcn_handle): Handle body as a
single expression instead of statement.
* pt-fcn-handle.h, pt-fcn-handle.cc (class tree_anon_fcn_handle):
Handle body as a single expression. Eliminate return list.
* pt-pr-code.h, pt-pr-code.cc (tree_print_code::print_fcn_handle_body):
Handle anonymous function handle body as single expression.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 11 Jun 2017 16:37:26 -0400 |
parents | 2699c5974844 |
children | ea879bc55272 |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-pr-code.cc Fri Jun 09 02:21:28 2017 -0400 +++ b/libinterp/parse-tree/pt-pr-code.cc Sun Jun 11 16:37:26 2017 -0400 @@ -52,7 +52,7 @@ os << ") "; - print_fcn_handle_body (afh.body ()); + print_fcn_handle_body (afh.expression ()); print_parens (afh, ")"); } @@ -1152,36 +1152,13 @@ } void - tree_print_code::print_fcn_handle_body (tree_statement_list *b) + tree_print_code::print_fcn_handle_body (tree_expression *e) { - if (b) + if (e) { - assert (b->length () == 1); - - tree_statement *s = b->front (); - - if (s) - { - if (s->is_expression ()) - { - tree_expression *e = s->expression (); - - if (e) - { - suppress_newlines++; - e->accept (*this); - suppress_newlines--; - } - } - else - { - tree_command *c = s->command (); - - suppress_newlines++; - c->accept (*this); - suppress_newlines--; - } - } + suppress_newlines++; + e->accept (*this); + suppress_newlines--; } }