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 1QYNTE-0001Ml-K0 for garchives@archives.gentoo.org; Sun, 19 Jun 2011 19:15:44 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 94E771C02E; Sun, 19 Jun 2011 19:15:37 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 660FE1C02E for ; Sun, 19 Jun 2011 19:15:37 +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 E61051B4017 for ; Sun, 19 Jun 2011 19:15:36 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id B556680040 for ; Sun, 19 Jun 2011 19:15:35 +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/test_expr.bash scripts/test_expr.bash.result X-VCS-Directories: scripts/ bashast/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: ae0cabbc1a5a36ac35b05710fb51f1098cf301e3 Date: Sun, 19 Jun 2011 19:15:35 +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: b5688dfbef460eba6df909b6287b6611 commit: ae0cabbc1a5a36ac35b05710fb51f1098cf301e3 Author: Mu Qiao gentoo org> AuthorDate: Tue Jun 14 08:21:34 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Sun Jun 19 19:13:39 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3Dae0cabbc Walker: support -a and -o in built-in test --- bashast/libbashWalker.g | 16 +++++++++++++++- scripts/test_expr.bash | 2 ++ scripts/test_expr.bash.result | 2 ++ 3 files changed, 19 insertions(+), 1 deletions(-) diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index f78259f..fda4ef6 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -143,6 +143,11 @@ options return std::string(reinterpret_cast(token->start), boost::numeric_cast(token->stop - token->start + 1))= ; } + + char get_char(pANTLR3_BASE_TREE node) + { + return *reinterpret_cast(node->getToken(node)->start); + } } } =20 @@ -622,7 +627,7 @@ common_condition returns[bool status] } // -o for shell option, -z -n for string, -abcdefghkprstuwxOGLSN for f= iles |^(op=3DLETTER string_expr) { - $status =3D internal::test_unary(*reinterpret_cast(op->g= etToken(op)->start), + $status =3D internal::test_unary(get_char(op), $string_expr.libbash_value); } |^(EQUALS left_str=3Dstring_expr right_str=3Dstring_expr) { @@ -659,6 +664,15 @@ keyword_condition returns[bool status] =20 builtin_condition returns[bool status] :^(NEGATION l=3Dbuiltin_condition) { $status =3D !l; } + |^(BUILTIN_LOGIC o=3DLETTER l=3Dbuiltin_condition r=3Dbuiltin_condition= ) { + char op =3D get_char(o); + if(op =3D=3D 'a') + $status =3D l && r; + else if(op =3D=3D 'o') + $status =3D l || r; + else + throw libbash::interpreter_exception(std::string("unrecognized operat= or in built-in test: ") + op); + } |s=3Dbuiltin_condition_primary { $status =3D s; }; =20 builtin_condition_primary returns[bool status] diff --git a/scripts/test_expr.bash b/scripts/test_expr.bash index f1f3093..04b5a62 100644 --- a/scripts/test_expr.bash +++ b/scripts/test_expr.bash @@ -50,3 +50,5 @@ i=3D2 unset i [[ "setup.py" =3D~ ^(setup\.py|nosetests|py\.test|trial(\ .*)?)$ ]] && e= cho true17 [[ "setup.py" =3D~ ^(setup\.p|nosetests|py\.test|trial(\ .*)?)$ ]] && ec= ho false +[ abc =3D bcd -o abc =3D abc ] && echo true18 +[ abc =3D bcd -a abc =3D abc ] || echo true19 diff --git a/scripts/test_expr.bash.result b/scripts/test_expr.bash.resul= t index 2082757..fb147eb 100644 --- a/scripts/test_expr.bash.result +++ b/scripts/test_expr.bash.result @@ -24,3 +24,5 @@ true14 true15 true16 true17 +true18 +true19