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 1Q9iLg-0007GY-U7 for garchives@archives.gentoo.org; Tue, 12 Apr 2011 18:30:01 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1AED61C06A; Tue, 12 Apr 2011 18:29:24 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id CC2171C06B for ; Tue, 12 Apr 2011 18:29:23 +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 667F41BC0CE for ; Tue, 12 Apr 2011 18:29:23 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id BD2C780079 for ; Tue, 12 Apr 2011 18:29:22 +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: <5b7cec85d9adeaee707cb3e74122c70aa96c6518.betelgeuse@gentoo> Subject: [gentoo-commits] proj/libbash:master commit in: scripts/, bashast/ X-VCS-Repository: proj/libbash X-VCS-Files: bashast/libbashWalker.g scripts/var_def.ebuild scripts/var_def.ebuild.result X-VCS-Directories: scripts/ bashast/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: 5b7cec85d9adeaee707cb3e74122c70aa96c6518 Date: Tue, 12 Apr 2011 18:29:22 +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: 683cc86b95c91b39abc12fa1e8125de2 commit: 5b7cec85d9adeaee707cb3e74122c70aa96c6518 Author: Mu Qiao gentoo org> AuthorDate: Tue Apr 12 07:19:42 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Tue Apr 12 12:08:11 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3D5b7cec85 Implement array element reference for string Now we can refer an array element as a string value. --- bashast/libbashWalker.g | 96 ++++++++++++++++++++++++-----------= ------ scripts/var_def.ebuild | 3 +- scripts/var_def.ebuild.result | 3 +- 3 files changed, 60 insertions(+), 42 deletions(-) diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index 33c18a6..1061c3f 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -45,11 +45,23 @@ start: list|EOF; =20 list: ^(LIST var_def+); =20 -name returns[std::string libbash_value]: +name_base returns[std::string libbash_value]: NAME {$libbash_value =3D walker->get_string($NAME);} | LETTER {$libbash_value =3D walker->get_string($LETTER);} | '_' {$libbash_value=3D"_";}; =20 +name returns[std::string libbash_value, unsigned index] +@init { + $index =3D 0; +}: + ^(libbash_name=3Dname_base value=3Darithmetics){ + $index =3D value; + $libbash_value =3D libbash_name; + } + |libbash_name=3Dname_base{ + $libbash_value =3D libbash_name; + }; + num returns[std::string libbash_value] options{ k=3D1; }: DIGIT { $libbash_value =3D walker->get_string($DIGIT); } @@ -60,14 +72,14 @@ var_def std::map values; int index =3D 0; }: - ^(EQUALS libbash_name=3Dname libbash_value=3Dword){ + ^(EQUALS libbash_name=3Dname_base libbash_value=3Dword){ walker->define(libbash_name, libbash_value); } - |^(EQUALS libbash_name=3Dname ^(ARRAY ( - (libbash_string=3Dstring_expr - |^(EQUALS value=3Darithmetics { index =3D value; } libbash_stri= ng=3Dstring_expr)) - { values[index++] =3D libbash_string; })* - )){ + |^(EQUALS libbash_name=3Dname_base ^(ARRAY ( + (libbash_string=3Dstring_expr + |^(EQUALS value=3Darithmetics { index =3D value; } libbash_str= ing=3Dstring_expr)) + { values[index++] =3D libbash_string; })* + )){ walker->define(libbash_name, values); }; =20 @@ -91,11 +103,15 @@ any_string returns[std::string libbash_value] any_token=3D. { $libbash_value =3D walker->get_string(any_token); }; =20 //Allowable variable names in the variable expansion -var_name returns[std::string libbash_value] -@after { - $libbash_value =3D walker->get_string($var_name.start); +var_name returns[std::string libbash_value, unsigned index] +@init { + $var_name.index =3D 0; }: - num|name; + libbash_string=3Dnum { $libbash_value =3D libbash_string; } + |name { + $libbash_value =3D $name.libbash_value; + $index =3D $name.index; + }; =20 var_expansion returns[std::string libbash_value]: ^(USE_DEFAULT var_name libbash_word=3Dword) { @@ -127,7 +143,7 @@ word returns[std::string libbash_value]: =20 //variable reference var_ref returns[std::string libbash_value]: - ^(VAR_REF libbash_name=3Dname) { $libbash_value =3D walker->resolve(libbash_name); } + ^(VAR_REF name) { $libbash_value =3D walker->resolve($name= .libbash_value, $name.index); } |^(VAR_REF libbash_string=3Dvar_expansion) { $libbash_value =3D libbash= _string; }; =20 // shell arithmetic @@ -157,45 +173,45 @@ arithmetics returns[int value] |^(ARITHMETIC_CONDITION cnd=3Darithmetics l=3Darithmetics r=3Darithmeti= cs){ $value =3D walker->arithmetic_condition(cnd, l, r); } - |^(VAR_REF libbash_name=3Dname) { - $value =3D walker->resolve(libbash_name); + |^(VAR_REF name) { + $value =3D walker->resolve($name.libbash_value); } - |^(PRE_INCR ^(VAR_REF libbash_name=3Dname)){ $value =3D walker->pre_inc= r(libbash_name); } - |^(PRE_DECR ^(VAR_REF libbash_name=3Dname)){ $value =3D walker->pre_dec= r(libbash_name); } - |^(POST_INCR ^(VAR_REF libbash_name=3Dname)){ $value =3D walker->post_i= ncr(libbash_name); } - |^(POST_DECR ^(VAR_REF libbash_name=3Dname)){ $value =3D walker->post_d= ecr(libbash_name); } - |^(EQUALS libbash_name=3Dname l=3Darithmetics) { - $value =3D walker->set_value(libbash_name, l); + |^(PRE_INCR ^(VAR_REF name)){ $value =3D walker->pre_incr($name.libbash= _value); } + |^(PRE_DECR ^(VAR_REF name)){ $value =3D walker->pre_decr($name.libbash= _value); } + |^(POST_INCR ^(VAR_REF name)){ $value =3D walker->post_incr($name.libba= sh_value); } + |^(POST_DECR ^(VAR_REF name)){ $value =3D walker->post_decr($name.libba= sh_value); } + |^(EQUALS name l=3Darithmetics) { + $value =3D walker->set_value($name.libbash_value, l); } - |^(MUL_ASSIGN libbash_name=3Dname l=3Darithmetics) { - $value =3D walker->assign(&interpreter::multiply, libbash_name, l); + |^(MUL_ASSIGN name l=3Darithmetics) { + $value =3D walker->assign(&interpreter::multiply, $name.libbash_value,= l); } - |^(DIVIDE_ASSIGN libbash_name=3Dname l=3Darithmetics) { - $value =3D walker->assign(&interpreter::divide, libbash_name, l); + |^(DIVIDE_ASSIGN name l=3Darithmetics) { + $value =3D walker->assign(&interpreter::divide, $name.libbash_value, l= ); } - |^(MOD_ASSIGN libbash_name=3Dname l=3Darithmetics) { - $value =3D walker->assign(&interpreter::mod, libbash_name, l); + |^(MOD_ASSIGN name l=3Darithmetics) { + $value =3D walker->assign(&interpreter::mod, $name.libbash_value, l); } - |^(PLUS_ASSIGN libbash_name=3Dname l=3Darithmetics) { - $value =3D walker->assign(&interpreter::plus, libbash_name, l); + |^(PLUS_ASSIGN name l=3Darithmetics) { + $value =3D walker->assign(&interpreter::plus, $name.libbash_value, l); } - |^(MINUS_ASSIGN libbash_name=3Dname l=3Darithmetics) { - $value =3D walker->assign(&interpreter::minus, libbash_name, l); + |^(MINUS_ASSIGN name l=3Darithmetics) { + $value =3D walker->assign(&interpreter::minus, $name.libbash_value, l)= ; } - |^(LSHIFT_ASSIGN libbash_name=3Dname l=3Darithmetics) { - $value =3D walker->assign(&interpreter::left_shift, libbash_name, l); + |^(LSHIFT_ASSIGN name l=3Darithmetics) { + $value =3D walker->assign(&interpreter::left_shift, $name.libbash_valu= e, l); } - |^(RSHIFT_ASSIGN libbash_name=3Dname l=3Darithmetics) { - $value =3D walker->assign(&interpreter::right_shift, libbash_name, l); + |^(RSHIFT_ASSIGN name l=3Darithmetics) { + $value =3D walker->assign(&interpreter::right_shift, $name.libbash_val= ue, l); } - |^(AND_ASSIGN libbash_name=3Dname l=3Darithmetics) { - $value =3D walker->assign(&interpreter::bitwiseand, libbash_name, l); + |^(AND_ASSIGN name l=3Darithmetics) { + $value =3D walker->assign(&interpreter::bitwiseand, $name.libbash_valu= e, l); } - |^(XOR_ASSIGN libbash_name=3Dname l=3Darithmetics) { - $value =3D walker->assign(&interpreter::bitwisexor, libbash_name, l); + |^(XOR_ASSIGN name l=3Darithmetics) { + $value =3D walker->assign(&interpreter::bitwisexor, $name.libbash_valu= e, l); } - |^(OR_ASSIGN libbash_name=3Dname l=3Darithmetics) { - $value =3D walker->assign(&interpreter::bitwiseor, libbash_name, l); + |^(OR_ASSIGN name l=3Darithmetics) { + $value =3D walker->assign(&interpreter::bitwiseor, $name.libbash_value= , l); } | NUMBER { $value =3D walker->parse_int($NUMBER);} | DIGIT { $value =3D walker->parse_int($DIGIT);} diff --git a/scripts/var_def.ebuild b/scripts/var_def.ebuild index 3dfeb80..a621409 100644 --- a/scripts/var_def.ebuild +++ b/scripts/var_def.ebuild @@ -12,4 +12,5 @@ DEPEND=3D"${RDEPEND} dev-util/pkgconfig" MY_PATCH=3Dldflags.patch PATCH=3D("1.patch" 2.patch) -ARRAY=3D(1 2 3 [5]=3D4) +ARRAY=3D(1 2 3 [5]=3D4 5) +ARRAY_LAST=3D${ARRAY[6]} diff --git a/scripts/var_def.ebuild.result b/scripts/var_def.ebuild.resul= t index 3e19cdb..b563a56 100644 --- a/scripts/var_def.ebuild.result +++ b/scripts/var_def.ebuild.result @@ -1,4 +1,5 @@ -ARRAY=3D1 2 3 4 +ARRAY=3D1 2 3 4 5 +ARRAY_LAST=3D5 DEPEND=3Ddev-db/sqlite:3 dev-util/pkgconfig DESCRIPTION=3DSunPinyin is a SLM (Statistical Language Model) based IME