From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QaPku-0004NH-EL for garchives@archives.gentoo.org; Sat, 25 Jun 2011 10:06:24 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B6C431C060; Sat, 25 Jun 2011 10:05:51 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 746EC1C060 for ; Sat, 25 Jun 2011 10:05:51 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CFED41B402F for ; Sat, 25 Jun 2011 10:05:50 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 2432F8003D for ; Sat, 25 Jun 2011 10:05:50 +0000 (UTC) From: "Petteri Räty" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Petteri Räty" Message-ID: <4a6aa796319c9dbc9ac1b50c846c6f4b009c196f.betelgeuse@gentoo> Subject: [gentoo-commits] proj/libbash:master commit in: scripts/, bashast/ X-VCS-Repository: proj/libbash X-VCS-Files: bashast/libbashWalker.g scripts/compound_command.bash scripts/compound_command.bash.result X-VCS-Directories: scripts/ bashast/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: 4a6aa796319c9dbc9ac1b50c846c6f4b009c196f Date: Sat, 25 Jun 2011 10:05:50 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 6c6d4752efe55f7f20789c7d2a67d370 commit: 4a6aa796319c9dbc9ac1b50c846c6f4b009c196f Author: Mu Qiao gentoo org> AuthorDate: Mon Jun 20 14:48:22 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Thu Jun 23 03:24:43 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3D4a6aa796 Walker: support break built-in --- bashast/libbashWalker.g | 24 ++++++++++- scripts/compound_command.bash | 79 ++++++++++++++++++++++++++++= ++++++ scripts/compound_command.bash.result | 9 ++-- 3 files changed, 107 insertions(+), 5 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 =20 SEEK(condition_index); =20 + ANTLR3_MARKER command_index; while(!has_condition || for_condition(ctx)) { + command_index =3D 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 =3D false; } | UNTIL { negate =3D true; }) { @@ -801,6 +815,8 @@ while_expr command_list(ctx); if(walker->get_status() =3D=3D (negate? 0 : 1)) break; + + command_index =3D 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 diff --git a/scripts/compound_command.bash b/scripts/compound_command.bas= h index 06b4f9e..ece5504 100644 --- a/scripts/compound_command.bash +++ b/scripts/compound_command.bash @@ -46,6 +46,22 @@ do echo $file done =20 +for file in foo bar +do + if [[ $file =3D=3D "foo" ]]; then + break + fi + echo $file +done + +for file in foo bar +do + if [[ $file =3D=3D "bar" ]]; then + break + fi + echo $file +done + for outer in 1 2 3 do for file in foo bar @@ -57,6 +73,17 @@ do done done =20 +for outer in 1 2 3 +do + for file in foo bar + do + if [[ $file =3D=3D "foo" && $outer =3D=3D 1 ]]; then + break 2 + fi + echo "$outer $file" + done +done + i=3D0; while [ $i !=3D 4 ] do @@ -80,6 +107,16 @@ do done =20 i=3D0 +while [ $i !=3D 4 ] +do + i=3D$(( i + 1 )) + if [[ $i =3D=3D 1 ]]; then + break + fi + echo $i +done + +i=3D0 j=3D1 while [ $i !=3D 4 ] do @@ -95,6 +132,22 @@ do done done =20 +i=3D0 +j=3D1 +while [ $i !=3D 4 ] +do + i=3D$(( i + 1 )) + =20 + while [ $j =3D=3D 1 ] + do + if [[ $i =3D=3D 1 ]]; then + break 2 + fi + echo $i + let ++j + done +done + i=3D0; until [ $i =3D=3D 4 ] do @@ -118,6 +171,16 @@ do done =20 i=3D0 +until [ $i =3D=3D 4 ] +do + i=3D$(( i + 1 )) + if [[ $i =3D=3D 1 ]]; then + break + fi + echo $i +done + +i=3D0 j=3D1 until [ $i =3D=3D 4 ] do @@ -133,6 +196,22 @@ do done done =20 +i=3D0 +j=3D1 +until [ $i =3D=3D 4 ] +do + i=3D$(( i + 1 )) + =20 + while [ $j =3D=3D 1 ] + do + if [[ $i =3D=3D 1 ]]; then + break 2 + fi + echo $i + let ++j + done +done + a=3D1 b=3D2 if [ $a =3D=3D $b ] diff --git a/scripts/compound_command.bash.result b/scripts/compound_comm= and.bash.result index 4662025..c083e6a 100644 --- a/scripts/compound_command.bash.result +++ b/scripts/compound_command.bash.result @@ -13,6 +13,7 @@ ghi 10 bar foo +foo 2 foo 2 bar 3 foo @@ -52,9 +53,9 @@ case end a=3D1 b=3D2 bar=3D -file=3Dbar +file=3Dfoo foo=3Dghi -i=3D4 -j=3D2 -outer=3D3 +i=3D1 +j=3D1 +outer=3D1 target=3D_