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 1Q9Xsr-00029a-Kd for garchives@archives.gentoo.org; Tue, 12 Apr 2011 07:19:33 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EB2FC1C0B3; Tue, 12 Apr 2011 07:19:16 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id BD7321C0B3 for ; Tue, 12 Apr 2011 07:19:16 +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 525AE1BC02E for ; Tue, 12 Apr 2011 07:19:16 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id B1FF680019 for ; Tue, 12 Apr 2011 07:19:15 +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: bashast/, bashast/gunit/ X-VCS-Repository: proj/libbash X-VCS-Files: bashast/bashast.g bashast/gunit/array.gunit X-VCS-Directories: bashast/ bashast/gunit/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: fc8333e273165af0d86ede790afa84e8eac8d283 Date: Tue, 12 Apr 2011 07:19:15 +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: 35f0eace98c0c8180687a81862ef103a commit: fc8333e273165af0d86ede790afa84e8eac8d283 Author: Petteri R=C3=A4ty petteriraty eu> AuthorDate: Tue Apr 12 07:11:14 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Tue Apr 12 07:11:14 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3Dfc8333e2 Refer to array indexes with arithmetic expressions You can refer to array members using arithmetic expressions like for example ${arr[i+3]}. --- bashast/bashast.g | 2 +- bashast/gunit/array.gunit | 1 + 2 files changed, 2 insertions(+), 1 deletions(-) diff --git a/bashast/bashast.g b/bashast/bashast.g index 510ef90..18f6913 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -259,7 +259,7 @@ parameter_replace_operator //Allowable refences to values //either directly or through array var_name: num - | name^ LSQUARE! (DIGIT+|AT|TIMES) RSQUARE! + | name^ LSQUARE! (AT|TIMES|explicit_arithmetic) RSQUARE! | name | POUND; //with bang the array syntax is used for array indexes diff --git a/bashast/gunit/array.gunit b/bashast/gunit/array.gunit index d21ed6a..f1e87e0 100644 --- a/bashast/gunit/array.gunit +++ b/bashast/gunit/array.gunit @@ -28,6 +28,7 @@ var_ref: "${asdf[0]:-default}" -> (VAR_REF (:- (asdf 0) (STRING default))) "${asdf[3]}" -> (VAR_REF (asdf 3)) "${asdf[4] }" -> (VAR_REF (asdf 4)) +"${asdf[i*2]}" -> (VAR_REF (asdf (* (VAR_REF i) 2)))) "${asdf[1]:2:2}" -> (VAR_REF (OFFSET (asdf 1) 2 2)) "${asdf[2]##word}" -> (VAR_REF (## (asdf 2) (STRING word))) "${asdf[3]%%word}" -> (VAR_REF (%% (asdf 3) (STRING word)))