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 1QF6P1-0008NR-8Z for garchives@archives.gentoo.org; Wed, 27 Apr 2011 15:11:43 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AA0381C03D; Wed, 27 Apr 2011 15:11:13 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 71BC41C03D for ; Wed, 27 Apr 2011 15:11:13 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 313B71B408F for ; Wed, 27 Apr 2011 15:11:13 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 7BD2D80510 for ; Wed, 27 Apr 2011 15:11:12 +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: 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: cf1db9bbcdd15525359fa96084d04c0e876dea54 Date: Wed, 27 Apr 2011 15:11:12 +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: 5c0b0e276c2a93a1f6a622694f5f7cea commit: cf1db9bbcdd15525359fa96084d04c0e876dea54 Author: Mu Qiao gentoo org> AuthorDate: Tue Apr 26 07:05:52 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Wed Apr 27 14:58:45 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3Dcf1db9bb Walker: support while loop --- bashast/libbashWalker.g | 27 ++++++++++++++++++++++++++- scripts/compound_command.bash | 12 ++++++++++++ scripts/compound_command.bash.result | 6 +++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index c616c88..01c080e 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -321,7 +321,8 @@ command_list: ^(LIST logic_command_list+); compound_command : ^(CURRENT_SHELL command_list) | ^(COMPOUND_COND cond_expr) - | for_expr; + | for_expr + | while_expr; =20 cond_expr :^(BUILTIN_TEST status=3Dbuiltin_condition) { walker->set_status(!statu= s); }; @@ -402,6 +403,30 @@ for_condition returns[int libbash_value] for_modification :^(FOR_MOD arithmetics); =20 +while_expr +@declarations { + ANTLR3_MARKER command_index; +} + :^(WHILE { + // omit the first DOWN token + SEEK(INDEX() + 1); + + command_index =3D INDEX(); + while(true) + { + command_list(ctx); + if(walker->get_status()) + break; + command_list(ctx); + SEEK(command_index); + } + // Skip the body and get out + seek_to_next_tree(ctx); + + // omit the last UP token + SEEK(INDEX() + 1); + }); + command_substitution returns[std::string libbash_value] @declarations { std::stringstream out; diff --git a/scripts/compound_command.bash b/scripts/compound_command.bas= h index ad3e4f4..9da53b8 100644 --- a/scripts/compound_command.bash +++ b/scripts/compound_command.bash @@ -22,3 +22,15 @@ for ((;i<0;)) do echo "Shouldn't print this" done + +i=3D0; +while [ $i !=3D 4 ] +do + i=3D$(( i + 1 )) + echo $i +done + +while [ $i \< 0 ] +do + echo "Shouldn't print this" +done diff --git a/scripts/compound_command.bash.result b/scripts/compound_comm= and.bash.result index c865c15..b2d305a 100644 --- a/scripts/compound_command.bash.result +++ b/scripts/compound_command.bash.result @@ -11,6 +11,10 @@ ghi 8 9 10 +1 +2 +3 +4 file=3D foo bar=20 foo=3Dghi -i=3D10 +i=3D4