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 1QOFlH-0000AS-20 for garchives@archives.gentoo.org; Sun, 22 May 2011 21:00:31 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 86B251C086; Sun, 22 May 2011 21:00:23 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 4D7951C086 for ; Sun, 22 May 2011 21:00: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 BF5E91B401D for ; Sun, 22 May 2011 21:00:22 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 11D8380506 for ; Sun, 22 May 2011 21:00: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: Subject: [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/ X-VCS-Repository: proj/libbash X-VCS-Files: bashast/bashast.g bashast/gunit/cond_main.gunit X-VCS-Directories: bashast/ bashast/gunit/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: a8be914d2ff0ff3516ed0ea1e9d775ba57c3c47d Date: Sun, 22 May 2011 21:00: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: 2aa774ac89cacf7173b9b71fc3935f61 commit: a8be914d2ff0ff3516ed0ea1e9d775ba57c3c47d Author: Mu Qiao gentoo org> AuthorDate: Mon May 16 12:24:09 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Sun May 22 16:11:39 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3Da8be914d Parser: use tokens instead of "OP" for keyword test OP["!=3D"] can't be understand by the walker grammar so we use virtual a token instead. "!=3D" and "=3D=3D" trigger bash pattern matching. --- bashast/bashast.g | 6 ++++-- bashast/gunit/cond_main.gunit | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bashast/bashast.g b/bashast/bashast.g index c4156ec..2a8e20b 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -68,6 +68,8 @@ tokens{ EXTENDED_MATCH_NONE; EXTENDED_MATCH_ANY; EXTENDED_MATCH_AT_LEAST_ONE; + MATCH_PATTERN; + NOT_MATCH_PATTERN; MATCH_ANY; MATCH_ANY_EXCEPT; MATCH_ALL; @@ -354,9 +356,9 @@ negate_builtin_primary : BANG BLANK+ builtin_cond_primary -> ^(NEGATION builtin_cond_primary); binary_str_op_keyword : bop - | EQUALS EQUALS -> OP["=3D=3D"] + | EQUALS EQUALS -> MATCH_PATTERN | EQUALS - | BANG EQUALS -> OP["!=3D"] + | BANG EQUALS -> NOT_MATCH_PATTERN | LESS_THAN | GREATER_THAN; binary_string_op_builtin diff --git a/bashast/gunit/cond_main.gunit b/bashast/gunit/cond_main.guni= t index 78ebbf9..eeef052 100644 --- a/bashast/gunit/cond_main.gunit +++ b/bashast/gunit/cond_main.gunit @@ -22,7 +22,9 @@ cond_expr: "[[ -a this/is.afile ]]" -> (KEYWORD_TEST (a (STRING this / is . afile))= ) "[ -n \"yar53\" ]" -> (BUILTIN_TEST (n (STRING (DOUBLE_QUOTED_STRING yar= 53)))) "test 5 -eq 6" -> (BUILTIN_TEST (eq (STRING 5) (STRING 6))) -"[[ \"asdf\" !=3D \"boo\" && -a filename ]]" -> (KEYWORD_TEST (&& (!=3D = (STRING (DOUBLE_QUOTED_STRING asdf)) (STRING (DOUBLE_QUOTED_STRING boo)))= (a (STRING filename)))) +"[[ \"asdf\" !=3D \"boo\" && -a filename ]]" -> (KEYWORD_TEST (&& (NOT_M= ATCH_PATTERN (STRING (DOUBLE_QUOTED_STRING asdf)) (STRING (DOUBLE_QUOTED_= STRING boo))) (a (STRING filename)))) +"[[ a =3D b ]]" -> (KEYWORD_TEST (=3D (STRING a) (STRING b))) +"[[ a =3D=3D b ]]" -> (KEYWORD_TEST (MATCH_PATTERN (STRING a) (STRING b)= )) "[[ true ]]" -> (KEYWORD_TEST (STRING true)) "[[ true && (false || three) ]]" -> (KEYWORD_TEST (&& (STRING true) (|| = (STRING false) (STRING three)))) "[ a =3D b ]" -> (BUILTIN_TEST (=3D (STRING a) (STRING b)))