Mercurial > hg > octave-lyh
comparison libinterp/parse-tree/pt-pr-code.cc @ 17257:923ce8b42db2
improve try-catch-statement to save exception to a variable (bug #33217)
* oct-parse.in.yy (except_command): Handle exception identifiers.
* oct-parse.in.yy, parse.h (octave_base_parser::make_try_command):
New arg, ID.
* pt-except.cc, pt-except.h (tree_try_catch_command::expr_id): New
data member.
(tree_command::tree_command): Initialize it.
(tree_command::~tree_command): Delete it.
(tree_command::identifier): New function.
* pt-check.cc (tree_checker::visit_try_catch_command): Check for valid
expr_id.
* pt-pr-code.cc (tree_print_code::visit_try_catch_command):
Print expr_id.
* pt-eval.cc (tree_evaluator::visit_try_catch_command): Assign message
and identifier to variable.
* try.tst: New test.
* NEWS: Note change.
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Tue, 13 Aug 2013 19:35:53 +0200 |
parents | 2fc554ffbc28 |
children |
comparison
equal
deleted
inserted
replaced
17256:0b2a0acd0315 | 17257:923ce8b42db2 |
---|---|
991 os << "try"; | 991 os << "try"; |
992 | 992 |
993 newline (); | 993 newline (); |
994 | 994 |
995 tree_statement_list *try_code = cmd.body (); | 995 tree_statement_list *try_code = cmd.body (); |
996 tree_identifier *expr_id = cmd.identifier (); | |
996 | 997 |
997 if (try_code) | 998 if (try_code) |
998 { | 999 { |
999 increment_indent_level (); | 1000 increment_indent_level (); |
1000 | 1001 |
1006 print_indented_comment (cmd.middle_comment ()); | 1007 print_indented_comment (cmd.middle_comment ()); |
1007 | 1008 |
1008 indent (); | 1009 indent (); |
1009 | 1010 |
1010 os << "catch"; | 1011 os << "catch"; |
1012 | |
1013 if (expr_id) | |
1014 { | |
1015 os << " "; | |
1016 expr_id->accept (*this); | |
1017 } | |
1011 | 1018 |
1012 newline (); | 1019 newline (); |
1013 | 1020 |
1014 tree_statement_list *catch_code = cmd.cleanup (); | 1021 tree_statement_list *catch_code = cmd.cleanup (); |
1015 | 1022 |