Mercurial > octave
diff libinterp/parse-tree/pt-fcn-handle.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 | 5cb3a2bb5e1e |
children | 214cb58ccc1c |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-fcn-handle.cc Fri Jun 09 02:21:28 2017 -0400 +++ b/libinterp/parse-tree/pt-fcn-handle.cc Sun Jun 11 16:37:26 2017 -0400 @@ -67,8 +67,7 @@ tree_anon_fcn_handle::~tree_anon_fcn_handle (void) { delete m_parameter_list; - delete m_return_list; - delete m_statement_list; + delete m_expression; } tree_expression * @@ -76,8 +75,7 @@ symbol_table::context_id) const { tree_parameter_list *param_list = parameter_list (); - tree_parameter_list *ret_list = return_list (); - tree_statement_list *stmt_list = body (); + tree_expression *expr = expression (); symbol_table::scope_id af_sid = scope (); symbol_table::scope_id af_parent_sid = parent_scope (); @@ -92,8 +90,7 @@ tree_anon_fcn_handle *new_afh = new tree_anon_fcn_handle (param_list ? param_list->dup (new_scope, 0) : 0, - ret_list ? ret_list->dup (new_scope, 0) : 0, - stmt_list ? stmt_list->dup (new_scope, 0) : 0, + expr ? expr->dup (new_scope, 0) : 0, new_scope, af_parent_sid, line (), column ()); new_afh->copy_base (*this);