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 1QK3iU-0003v1-MM for garchives@archives.gentoo.org; Wed, 11 May 2011 07:20:19 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D4E6A1C0D2; Wed, 11 May 2011 07:19:36 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 88C971C0D2 for ; Wed, 11 May 2011 07:19:36 +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 067941B40B7 for ; Wed, 11 May 2011 07:19:36 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 672508050B for ; Wed, 11 May 2011 07:19:35 +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: <99716ee225f60d40dfb1a49be840c0abe3557c00.betelgeuse@gentoo> Subject: [gentoo-commits] proj/libbash:master commit in: scripts/, bashast/ X-VCS-Repository: proj/libbash X-VCS-Files: bashast/libbashWalker.g scripts/compound_command.bash scripts/compound_command.bash.result X-VCS-Directories: scripts/ bashast/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: 99716ee225f60d40dfb1a49be840c0abe3557c00 Date: Wed, 11 May 2011 07:19:35 +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: cd716edb9a1eececd913bd602fdb98e6 commit: 99716ee225f60d40dfb1a49be840c0abe3557c00 Author: Mu Qiao gentoo org> AuthorDate: Mon May 9 08:10:54 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Wed May 11 06:45:15 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3D99716ee2 Walker: support MATCH_ANY_EXCEPT and MATCH_PATTERN Patterns like [abc] and [!abc] are supported now. --- bashast/libbashWalker.g | 51 ++++++++++++++++++++++++++++= ------ scripts/compound_command.bash | 25 ++++++++++++++++ scripts/compound_command.bash.result | 5 ++- 3 files changed, 71 insertions(+), 10 deletions(-) diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index 16e4624..38cd459 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -175,21 +175,40 @@ string_expr returns[std::string libbash_value, bool= quoted] $quoted =3D true; } :^(STRING ( - (DOUBLE_QUOTED_STRING) =3D> - ^(DOUBLE_QUOTED_STRING (libbash_string=3Ddouble_quoted_string { $libb= ash_value +=3D libbash_string; })*) - |(ARITHMETIC_EXPRESSION) =3D> - ^(ARITHMETIC_EXPRESSION value=3Darithmetics { - $libbash_value +=3D boost::lexical_cast(value); $quoted= =3D false; - }) - |(var_ref[false]) =3D> libbash_string=3Dvar_ref[false] { $libbash_valu= e +=3D libbash_string; $quoted =3D false; } - |libbash_string=3Dcommand_substitution { $libbash_value +=3D libbash_s= tring; $quoted =3D false; } - |(libbash_string=3Dany_string { $libbash_value +=3D libbash_string; $q= uoted =3D false; }) + string_part { + $libbash_value +=3D $string_part.libbash_value; + $quoted =3D $string_part.quoted; + } )+); =20 +string_part returns[std::string libbash_value, bool quoted] +@init { + $quoted =3D false; +} + :(DOUBLE_QUOTED_STRING) =3D> + ^(DOUBLE_QUOTED_STRING (libbash_string=3Ddouble_quoted_string { + $libbash_value +=3D libbash_string; + $quoted =3D true; + })*) + |(ARITHMETIC_EXPRESSION) =3D> + ^(ARITHMETIC_EXPRESSION value=3Darithmetics { + $libbash_value =3D boost::lexical_cast(value); + }) + |(var_ref[false]) =3D> libbash_string=3Dvar_ref[false] { + $libbash_value =3D libbash_string; + } + |libbash_string=3Dcommand_substitution { + $libbash_value =3D libbash_string; + } + |(libbash_string=3Dany_string { + $libbash_value =3D libbash_string; + }); + bash_pattern[boost::xpressive::sregex& pattern] @declarations { using namespace boost::xpressive; bool do_append =3D false; + bool negation; } :^(STRING ( (DOUBLE_QUOTED_STRING) =3D> @@ -202,6 +221,20 @@ bash_pattern[boost::xpressive::sregex& pattern] |(MATCH_ONE) =3D> MATCH_ONE { append($pattern, _, do_append); } + |(MATCH_ANY_EXCEPT|MATCH_PATTERN) =3D> + ^((MATCH_ANY_EXCEPT { negation =3D true; } | MATCH_PATTERN { negation = =3D false;}) s=3Dstring_part) { + if(s.libbash_value.empty()) + return; + + auto char_set =3D set =3D as_xpr(s.libbash_value[0]); + for(auto iter =3D s.libbash_value.begin() + 1; iter !=3D s.libbash_va= lue.end(); ++iter) + char_set =3D (char_set | *iter); + + if(negation) + append($pattern, ~char_set, do_append); + else + append($pattern, char_set, do_append); + } |(libbash_string=3Dany_string { append($pattern, as_xpr(libbash_string), do_append); }) diff --git a/scripts/compound_command.bash b/scripts/compound_command.bas= h index 1bd7943..3a3c5d8 100644 --- a/scripts/compound_command.bash +++ b/scripts/compound_command.bash @@ -110,4 +110,29 @@ case $target in echo "default" ;; esac +target=3Da +case $target in + [def]) + echo "Shouldn't print this" + ;; + [abc]) + echo yep + ;; +esac +case $target in + [def]) + echo "Shouldn't print this" + ;; + [a]) + echo yep + ;; +esac +case $target in + [!abc]) + echo "Shouldn't print this" + ;; + [!def]) + echo yep + ;; +esac echo "case end" diff --git a/scripts/compound_command.bash.result b/scripts/compound_comm= and.bash.result index 08ddf31..1ee0f91 100644 --- a/scripts/compound_command.bash.result +++ b/scripts/compound_command.bash.result @@ -25,10 +25,13 @@ ghi 1 yep default +yep +yep +yep case end a=3D1 b=3D2 file=3D foo bar=20 foo=3Dghi i=3D4 -target=3Dxyz +target=3Da