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 1QBPhC-0002TB-86 for garchives@archives.gentoo.org; Sun, 17 Apr 2011 10:59:14 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7ABD01C0AD; Sun, 17 Apr 2011 10:58:32 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 483EE1C0B1 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 02EF51B408F 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 608A980075 for ; Sun, 17 Apr 2011 10:58:31 +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: <32ea83a17790cfc700bce50cd91b8aa2129a6014.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/brace.gunit X-VCS-Directories: bashast/ bashast/gunit/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: 32ea83a17790cfc700bce50cd91b8aa2129a6014 Date: Sun, 17 Apr 2011 10:58:31 +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: 85b59d781a96c10e910e437ae65023ad commit: 32ea83a17790cfc700bce50cd91b8aa2129a6014 Author: Petteri R=C3=A4ty petteriraty eu> AuthorDate: Sat Apr 16 12:43:32 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Sun Apr 17 10:57:03 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3D32ea83a1 Parser: empty atoms in brace expansion With expressions like README{.txt,} you can expand to the word with and without the extension. We now parse these expressions and mark the result in the AST with a virtual token. --- bashast/bashast.g | 4 +++- bashast/gunit/brace.gunit | 1 + 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/bashast/bashast.g b/bashast/bashast.g index 468a460..b318f3c 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -29,6 +29,7 @@ tokens{ ARRAY; ARRAY_SIZE; BRACE_EXP; + EMPTY_BRACE_EXPANSION_ATOM; COMMAND_SUB; CASE_PATTERN; SUBSHELL; @@ -162,7 +163,8 @@ brace_expansion_part : brace_expansion | ((~COMMA) =3D> fname_part)+ -> ^(STRING fname_part+) | var_ref - | command_sub; + | command_sub + | -> EMPTY_BRACE_EXPANSION_ATOM; commasep: brace_expansion_part(COMMA! brace_expansion_part)+; command_sub : DOLLAR LPAREN BLANK* pipeline BLANK? RPAREN -> ^(COMMAND_SUB pipeline= ) diff --git a/bashast/gunit/brace.gunit b/bashast/gunit/brace.gunit index 2030d58..c9a7ba9 100644 --- a/bashast/gunit/brace.gunit +++ b/bashast/gunit/brace.gunit @@ -23,6 +23,7 @@ brace_expansion: "{a,b,c}" -> (BRACE_EXP (STRING a) (STRING b) (STRING c)) "{a..d}" -> (BRACE_EXP (.. a d)) "{{a,b},c,d}" -> (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c)= (STRING d)) +"{.txt,,}" -> (BRACE_EXP (STRING . txt) EMPTY_BRACE_EXPANSION_ATOM EMPTY= _BRACE_EXPANSION_ATOM) =20 fname: "a{b,c}" -> (STRING a (BRACE_EXP (STRING b) (STRING c)))