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 1QBPiU-0002kT-WD for garchives@archives.gentoo.org; Sun, 17 Apr 2011 11:00:35 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2F7F51C0C4; Sun, 17 Apr 2011 10:58:38 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id F0D891C0C2 for ; Sun, 17 Apr 2011 10:58:32 +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 ABD7B1B408F for ; Sun, 17 Apr 2011 10:58:32 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 0B9128006E for ; Sun, 17 Apr 2011 10:58:32 +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: <1d8b7e32a092a2abcd9d95282eb6c2d9df31f95d.betelgeuse@gentoo> Subject: [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/ X-VCS-Repository: proj/libbash X-VCS-Files: bashast/bashast.g bashast/gunit/arith_main.gunit X-VCS-Directories: bashast/ bashast/gunit/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: 1d8b7e32a092a2abcd9d95282eb6c2d9df31f95d Date: Sun, 17 Apr 2011 10:58:32 +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: 89efdb19720dc740f8fa1fa406444c3f commit: 1d8b7e32a092a2abcd9d95282eb6c2d9df31f95d Author: Petteri R=C3=A4ty petteriraty eu> AuthorDate: Sat Apr 16 16:31:14 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Sun Apr 17 10:57:04 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3D1d8b7e32 Parser: deprecated syntax for arithmetic expansion Eclasses seem to be using a deprecated form of arithmetic expansion with square brackets that bash does not document anywhere. This is now supported by the parser. --- bashast/bashast.g | 8 ++++++-- bashast/gunit/arith_main.gunit | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bashast/bashast.g b/bashast/bashast.g index 7939229..a3b7314 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -457,11 +457,15 @@ extended_pattern_match | AT LPAREN fname (PIPE fname)* RPAREN -> ^(MATCH_EXACTLY_ONE fname+) | BANG LPAREN fname (PIPE fname)* RPAREN -> ^(MATCH_NONE fname+); //Arithmetic expansion +//the square bracket from is deprecated +//http://permalink.gmane.org/gmane.comp.shells.bash.bugs/14479 arithmetic_expansion - : DOLLAR LLPAREN BLANK* arithmetics BLANK* RRPAREN -> ^(ARITHMETIC_EXPR= ESSION arithmetics); + : DOLLAR LLPAREN BLANK* arithmetics BLANK* RRPAREN -> ^(ARITHMETIC_EXPR= ESSION arithmetics) + | DOLLAR LSQUARE BLANK* arithmetics BLANK* RSQUARE -> ^(ARITHMETIC_EXPR= ESSION arithmetics); //explicit arithmetic in places like array indexes explicit_arithmetic - : (DOLLAR LLPAREN BLANK*)? arithmetics (BLANK* RRPAREN)? -> arithmetics= ; + : (DOLLAR LLPAREN BLANK*)? arithmetics (BLANK* RRPAREN)? -> arithmetics + | (DOLLAR LSQUARE BLANK*)? arithmetics (BLANK* RSQUARE)? -> arithmetics= ; //The comma operator for arithmetic expansions arithmetics : arithmetic (BLANK!* COMMA! BLANK!* arithmetic)*; diff --git a/bashast/gunit/arith_main.gunit b/bashast/gunit/arith_main.gu= nit index 0f85d55..d8697af 100644 --- a/bashast/gunit/arith_main.gunit +++ b/bashast/gunit/arith_main.gunit @@ -125,6 +125,7 @@ arithmetic_condition: =20 arithmetic_expansion: "$((5+4, 3+2, a*b))" -> (ARITHMETIC_EXPRESSION (+ 5 4) (+ 3 2) (* (VAR_R= EF a) (VAR_REF b))) +"$[1]" -> (ARITHMETIC_EXPRESSION 1) =20 start: "echo $(( 3 + 2 ))" -> (LIST (COMMAND (STRING echo) (STRING (ARITHMETIC_= EXPRESSION (+ 3 2)))))