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 1QAEWQ-0001Yw-Im for garchives@archives.gentoo.org; Thu, 14 Apr 2011 04:51:14 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5E33C1C01F; Thu, 14 Apr 2011 04:50:16 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 191C21C024 for ; Thu, 14 Apr 2011 04:50:15 +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 636211B4158 for ; Thu, 14 Apr 2011 04:50:15 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 74FCB80076 for ; Thu, 14 Apr 2011 04:50:14 +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: <793965cb2dac5bb015538620796bc628b7618f44.betelgeuse@gentoo> Subject: [gentoo-commits] proj/libbash:master commit in: scripts/, src/core/, bashast/, test/ X-VCS-Repository: proj/libbash X-VCS-Files: bashast/bashast.g bashast/libbashWalker.g scripts/var_def.ebuild scripts/var_def.ebuild.result src/core/interpreter.h test/variable_printer.cpp X-VCS-Directories: scripts/ src/core/ bashast/ test/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: 793965cb2dac5bb015538620796bc628b7618f44 Date: Thu, 14 Apr 2011 04:50:14 +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: 65c0efade3b562fc436cecdd7a030739 commit: 793965cb2dac5bb015538620796bc628b7618f44 Author: Mu Qiao gentoo org> AuthorDate: Wed Apr 13 02:29:35 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Wed Apr 13 08:26:40 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3D793965cb Support assigning empty value to variable Syntax like 'a=3D' and 'a[1]=3D' is supported now. --- bashast/bashast.g | 4 ++-- bashast/libbashWalker.g | 5 +++-- scripts/var_def.ebuild | 7 +++++++ scripts/var_def.ebuild.result | 4 ++++ src/core/interpreter.h | 7 ++++--- test/variable_printer.cpp | 2 +- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/bashast/bashast.g b/bashast/bashast.g index 74fd5df..5fc5e7b 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -214,8 +214,8 @@ cond_comparison //Defining a variable //It's not legal to do FOO[1]=3D(a b c) var_def - : name LSQUARE BLANK? explicit_arithmetic BLANK* RSQUARE EQUALS fname -= > ^(EQUALS ^(name explicit_arithmetic) fname) - | name EQUALS^ value; + : name LSQUARE BLANK? explicit_arithmetic BLANK* RSQUARE EQUALS fname? = -> ^(EQUALS ^(name explicit_arithmetic) fname?) + | name EQUALS^ value?; //Possible values of a variable value : fname | LPAREN! wspace!? arr_val RPAREN!; diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index f4fff5d..43304f1 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -71,9 +71,10 @@ var_def @declarations { std::map values; int index =3D 0; + bool is_null =3D true; }: - ^(EQUALS name libbash_string=3Dstring_expr){ - walker->set_value($name.libbash_value, libbash_string, $name.index); + ^(EQUALS name (libbash_string=3Dstring_expr { is_null =3D false; })?){ + walker->set_value($name.libbash_value, libbash_string, $name.index, is= _null); } |^(EQUALS libbash_name=3Dname_base ^(ARRAY ( (libbash_string=3Dstring_expr diff --git a/scripts/var_def.ebuild b/scripts/var_def.ebuild index 5d336ee..06ebb3b 100644 --- a/scripts/var_def.ebuild +++ b/scripts/var_def.ebuild @@ -16,5 +16,12 @@ ARRAY=3D(1 2 3 [5]=3D4 5) ARRAY2=3D(1 2 3) ARRAY2[2]=3D4 ARRAY2[3]=3D5 +EMPTY=3D ARRAY_LAST=3D${ARRAY[6]} PARTIAL[5]=3D5 +EMPTY_ARRAY=3D() +ARRAY3=3D(1 2 3) +ARRAY3[0]=3D +ARRAY4=3D(1 2 3) +# The following one is equivalent to ARRAY4[0]=3D +ARRAY4=3D diff --git a/scripts/var_def.ebuild.result b/scripts/var_def.ebuild.resul= t index f288519..6433df7 100644 --- a/scripts/var_def.ebuild.result +++ b/scripts/var_def.ebuild.result @@ -1,10 +1,14 @@ ARRAY=3D1 2 3 4 5 ARRAY2=3D1 2 4 5 +ARRAY3=3D2 3 +ARRAY4=3D2 3 ARRAY_LAST=3D5 DEPEND=3Ddev-db/sqlite:3 dev-util/pkgconfig DESCRIPTION=3DSunPinyin is a SLM (Statistical Language Model) based IME EAPI=3D1 +EMPTY=3D +EMPTY_ARRAY=3D HOMEPAGE=3Dhttp://sunpinyin.googlecode.com IUSE=3D KEYWORDS=3D~amd64 ~x86 diff --git a/src/core/interpreter.h b/src/core/interpreter.h index 9166379..1e2babe 100644 --- a/src/core/interpreter.h +++ b/src/core/interpreter.h @@ -418,13 +418,14 @@ public: template const T& set_value(const std::string& name, const T& new_value, - const unsigned index=3D0) + const unsigned index=3D0, + bool is_null=3Dfalse) { std::shared_ptr value =3D members.resolve(name); if(!value) - define(name, new_value, false); + define(name, new_value, false, is_null); else - value->set_value(new_value, index); + value->set_value(new_value, index, is_null); return new_value; } =20 diff --git a/test/variable_printer.cpp b/test/variable_printer.cpp index cb17b9d..32fc161 100644 --- a/test/variable_printer.cpp +++ b/test/variable_printer.cpp @@ -46,7 +46,7 @@ int main(int argc, char** argv) std::map> sorted(variables.begin= (), variables.end()); =20 using namespace boost::spirit::karma; - std::cout << format((string << '=3D' << (string % ' ')) % eol, sorted)= << std::endl; + std::cout << format((string << '=3D' << -(string % ' ')) % eol, sorted= ) << std::endl; =20 return 0; }