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 1QaQ8A-0006Xk-Bm for garchives@archives.gentoo.org; Sat, 25 Jun 2011 10:30:31 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D86561C039; Sat, 25 Jun 2011 10:30:17 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 8D81D1C039 for ; Sat, 25 Jun 2011 10:30:17 +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 ECE581B401D for ; Sat, 25 Jun 2011 10:30:16 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 51EBB8003E for ; Sat, 25 Jun 2011 10:30:16 +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/binary_arithmetic.bash scripts/binary_arithmetic.bash.result X-VCS-Directories: scripts/ bashast/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: ba6972dbe97c47614f4aeef8187ae15e08b57ee2 Date: Sat, 25 Jun 2011 10:30:16 +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: 06f711c57818cd44260c76770ae13dbb commit: ba6972dbe97c47614f4aeef8187ae15e08b57ee2 Author: Mu Qiao gentoo org> AuthorDate: Mon Jun 20 09:55:48 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Wed Jun 22 11:53:01 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3Dba6972db Walker: support shortcut capability for logic or --- bashast/libbashWalker.g | 22 ++++++++++++++++++++-- scripts/binary_arithmetic.bash | 1 + scripts/binary_arithmetic.bash.result | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index fda4ef6..99d7f53 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -71,7 +71,7 @@ options index =3D value; } =20 - // seek to LT(2) and consume + // skip to next tree void seek_to_next_tree(plibbashWalker ctx) { // Current depth of the tree we are traversing @@ -95,6 +95,14 @@ options CONSUME(); } =20 + void skip_next_token_or_tree(plibbashWalker ctx) + { + if(LA(2) !=3D DOWN) + SEEK(INDEX() + 1); + else + seek_to_next_tree(ctx); + } + // The method is used to append a pattern with another one. Because it= 's not allowed to append an empty pattern, // we need the argument 'do_append' to indicate whether the pattern is= empty. 'do_append' will be set to true after // the first assignment. @@ -953,7 +961,17 @@ primary returns[std::string libbash_value, unsigned = index] =20 // shell arithmetic arithmetics returns[int value] - :^(LOGICOR l=3Darithmetics r=3Darithmetics) { $value =3D l || r; } + :^(LOGICOR l=3Darithmetics { + if(l) + { + skip_next_token_or_tree(ctx); + $value =3D 1; + } + else + { + $value =3D (arithmetics(ctx) !=3D 0); + } + }) |^(LOGICAND l=3Darithmetics r=3Darithmetics) { $value =3D l && r; } |^(PIPE l=3Darithmetics r=3Darithmetics) { $value =3D l | r; } |^(CARET l=3Darithmetics r=3Darithmetics) { $value =3D l ^ r; } diff --git a/scripts/binary_arithmetic.bash b/scripts/binary_arithmetic.b= ash index 330d07b..114655a 100644 --- a/scripts/binary_arithmetic.bash +++ b/scripts/binary_arithmetic.bash @@ -63,3 +63,4 @@ FOO057=3D"$((${FOO056}++))" FOO058=3D"$((${FOO056}+=3D10))" ARRAY=3D(1 2 3 4 5) FOO059=3D"$((100**0))" +FOO060=3D"$((FOO059||FOO059++))" diff --git a/scripts/binary_arithmetic.bash.result b/scripts/binary_arith= metic.bash.result index de065d6..740548d 100644 --- a/scripts/binary_arithmetic.bash.result +++ b/scripts/binary_arithmetic.bash.result @@ -58,5 +58,6 @@ FOO056=3Dvalue FOO057=3D100 FOO058=3D111 FOO059=3D1 +FOO060=3D1 PARTIAL=3D5 value=3D111