diff options
author | Mu Qiao <qiaomuf@gentoo.org> | 2011-06-20 22:48:22 +0800 |
---|---|---|
committer | Mu Qiao <qiaomuf@gentoo.org> | 2011-06-23 11:24:43 +0800 |
commit | 4a6aa796319c9dbc9ac1b50c846c6f4b009c196f (patch) | |
tree | 40d689029130421e5c5d5f817e08aa14a77ce4c2 /bashast/libbashWalker.g | |
parent | Walker: fix a bug in for each loop (diff) | |
download | libbash-4a6aa796319c9dbc9ac1b50c846c6f4b009c196f.tar.gz libbash-4a6aa796319c9dbc9ac1b50c846c6f4b009c196f.tar.bz2 libbash-4a6aa796319c9dbc9ac1b50c846c6f4b009c196f.zip |
Walker: support break built-in
Diffstat (limited to 'bashast/libbashWalker.g')
-rw-r--r-- | bashast/libbashWalker.g | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index 02e2f33..2bd446d 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -719,6 +719,12 @@ for_expr { e.rethrow_unless_correct_frame(); } + catch(break_exception& e) + { + e.rethrow_unless_correct_frame(); + SEEK(commands_index); + break; + } SEEK(commands_index); } seek_to_next_tree(ctx); @@ -743,8 +749,10 @@ for_expr SEEK(condition_index); + ANTLR3_MARKER command_index; while(!has_condition || for_condition(ctx)) { + command_index = INDEX(); try { command_list(ctx); @@ -758,10 +766,15 @@ for_expr SEEK(modification_index); for_modification(ctx); } - SEEK(condition_index); continue; } + catch(break_exception& e) + { + e.rethrow_unless_correct_frame(); + SEEK(command_index); + break; + } if(has_modification) for_modification(ctx); SEEK(condition_index); @@ -789,6 +802,7 @@ for_modification while_expr @declarations { ANTLR3_MARKER condition_index; + ANTLR3_MARKER command_index; bool negate; } :^((WHILE { negate = false; } | UNTIL { negate = true; }) { @@ -801,6 +815,8 @@ while_expr command_list(ctx); if(walker->get_status() == (negate? 0 : 1)) break; + + command_index = INDEX(); try { command_list(ctx); @@ -811,6 +827,12 @@ while_expr SEEK(condition_index); continue; } + catch(break_exception& e) + { + e.rethrow_unless_correct_frame(); + SEEK(command_index); + break; + } SEEK(condition_index); } // Skip the body and get out |