Mercurial > octave
diff libinterp/parse-tree/oct-parse.in.yy @ 17283:e6c0ac8ce5b6
eliminate parse conflicts introduced by changeset 923ce8b42db2
* oct-parse.in.yy (opt_identifier): Delete.
(TRY): Simplify grammar.
(octave_base_parser::make_try_command): Pass separator token instead
of exception identifier. Handle exception identifier here based on
context instead of in grammar rules.
* parse.h (octave_base_parser::make_try_command): Fix decl.
* try.tst: New tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Aug 2013 06:42:54 -0400 |
parents | bc924baa2c4e |
children | 8e2906e2fb26 |
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.in.yy Mon Aug 19 22:24:05 2013 -0700 +++ b/libinterp/parse-tree/oct-parse.in.yy Tue Aug 20 06:42:54 2013 -0400 @@ -240,7 +240,7 @@ %type <tree_expression_type> matrix cell %type <tree_expression_type> primary_expr oper_expr %type <tree_expression_type> simple_expr colon_expr assign_expr expression -%type <tree_identifier_type> identifier fcn_name magic_tilde opt_identifier +%type <tree_identifier_type> identifier fcn_name magic_tilde %type <tree_identifier_type> superclass_identifier meta_identifier %type <octave_user_function_type> function1 function2 classdef1 %type <tree_index_expression_type> word_list_cmd @@ -975,15 +975,10 @@ if (! ($$ = parser.make_unwind_command ($1, $4, $8, $9, $2, $6))) ABORT_PARSE; } - | TRY stash_comment opt_sep opt_list CATCH list END + | TRY stash_comment opt_sep opt_list CATCH stash_comment + opt_sep opt_list END { - if (! ($$ = parser.make_try_command ($1, $4, $6, 0, $7, $2, 0))) - ABORT_PARSE; - } - | TRY stash_comment opt_sep opt_list CATCH opt_identifier - stash_comment opt_sep opt_list END - { - if (! ($$ = parser.make_try_command ($1, $4, $9, $6, $10, $2, $7))) + if (! ($$ = parser.make_try_command ($1, $4, $7, $8, $9, $2, $6))) ABORT_PARSE; } | TRY stash_comment opt_sep opt_list END @@ -993,12 +988,6 @@ } ; -opt_identifier: // empty - { $$ = 0; } - | identifier sep - { $$ = $1; } - ; - // =========================================== // Some 'subroutines' for function definitions // =========================================== @@ -2201,8 +2190,8 @@ tree_command * octave_base_parser::make_try_command (token *try_tok, tree_statement_list *body, + char catch_sep, tree_statement_list *cleanup_stmts, - tree_identifier *id, token *end_tok, octave_comment_list *lc, octave_comment_list *mc) @@ -2216,6 +2205,25 @@ int l = try_tok->line (); int c = try_tok->column (); + tree_identifier *id = 0; + + if (! catch_sep && cleanup_stmts && ! cleanup_stmts->empty ()) + { + tree_statement *stmt = cleanup_stmts->front (); + + if (stmt) + { + tree_expression *expr = stmt->expression (); + + if (expr && expr->is_identifier ()) + { + id = dynamic_cast<tree_identifier *> (expr); + + cleanup_stmts->pop_front (); + } + } + } + retval = new tree_try_catch_command (body, cleanup_stmts, id, lc, mc, tc, l, c); }