Gentoo Archives: gentoo-commits

From: "Petteri Räty" <betelgeuse@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/
Date: Tue, 14 Jun 2011 08:29:02
Message-Id: 581066529adf685ca48bd7cdc2a2004a77141752.betelgeuse@gentoo
1 commit: 581066529adf685ca48bd7cdc2a2004a77141752
2 Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
3 AuthorDate: Sat Jun 11 13:08:39 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Tue Jun 14 07:35:51 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=58106652
7
8 Parser: fix bracket pattern match negation
9
10 The negation operator is supposed to be right after the opening left
11 bracket. The right bracket will come after it when it's part of the
12 matched characters.
13
14 ---
15 bashast/bashast.g | 16 ++++++----------
16 bashast/gunit/fname.gunit | 1 +
17 2 files changed, 7 insertions(+), 10 deletions(-)
18
19 diff --git a/bashast/bashast.g b/bashast/bashast.g
20 index 24b94f7..02a36ca 100644
21 --- a/bashast/bashast.g
22 +++ b/bashast/bashast.g
23 @@ -455,20 +455,16 @@ pattern_match_trigger
24 | AT;
25 //Pattern matching using brackets
26 bracket_pattern_match
27 - : LSQUARE! bracket_pattern_match_operator
28 + : LSQUARE! bracket_pattern_match_operator^ pattern_match RSQUARE!
29 | TIMES -> MATCH_ALL
30 | QMARK -> MATCH_ONE;
31 bracket_pattern_match_operator
32 - : RSQUARE (BANG|CARET) pattern_match RSQUARE -> ^(MATCH_ANY_EXCEPT RSQUARE pattern_match)
33 - | RSQUARE pattern_match RSQUARE -> ^(MATCH_ANY RSQUARE pattern_match)
34 - | (BANG|CARET) pattern_match RSQUARE -> ^(MATCH_ANY_EXCEPT pattern_match)
35 - | pattern_match RSQUARE -> ^(MATCH_ANY pattern_match);
36 -pattern_match
37 - : pattern_match_atom+;
38 + : (BANG) => BANG -> MATCH_ANY_EXCEPT
39 + | (CARET) => CARET -> MATCH_ANY_EXCEPT
40 + | -> MATCH_ANY;
41 //allowable patterns with bracket pattern matching
42 -pattern_match_atom
43 - : pattern_class_match
44 - | (~RSQUARE) => fname_part;
45 +pattern_match
46 + : (pattern_class_match|fname_part) (pattern_class_match| (~RSQUARE) => fname_part)*;
47
48 //special class patterns to match: [:alpha:] etc
49 pattern_class_match
50
51 diff --git a/bashast/gunit/fname.gunit b/bashast/gunit/fname.gunit
52 index 799570d..621b29d 100644
53 --- a/bashast/gunit/fname.gunit
54 +++ b/bashast/gunit/fname.gunit
55 @@ -56,6 +56,7 @@ fname:
56 "ab[!d-h]" -> (STRING ab (MATCH_ANY_EXCEPT d - h))
57 "ab[^d-h]" -> (STRING ab (MATCH_ANY_EXCEPT d - h))
58 "ab[]c]" -> (STRING ab (MATCH_ANY ] c))
59 +"ab[]!]" -> (STRING ab (MATCH_ANY ] !))
60 "ab[:alpha:]" -> (STRING ab (MATCH_ANY : alpha :))
61 "ab[=c=]" -> (STRING ab (MATCH_ANY = c =))
62 "ab[.c.]" -> (STRING ab (MATCH_ANY . c .))