globs: making glob-matches? support wildcards.

locals-and-roots
John Benediktsson 2016-04-06 14:02:48 -07:00
parent 6581741a92
commit a5f117c88f
2 changed files with 7 additions and 1 deletions

View File

@ -22,6 +22,8 @@ tools.test ;
{ f } [ "foo" "bar" append-path "*" glob-matches? ] unit-test
{ t } [ "foo" "bar" append-path "*" "*" append-path glob-matches? ] unit-test
{ t } [ "foo" "bar" append-path "**/bar" glob-matches? ] unit-test
{ t } [ "foo" "bar" append-path "**/b*" glob-matches? ] unit-test
{ f } [ "foo" "bar" append-path "foo?bar" glob-matches? ] unit-test
{ t } [ "foo" "bar" append-path "fo?" "bar" append-path glob-matches? ] unit-test

View File

@ -9,6 +9,9 @@ IN: globs
: not-path-separator ( -- sep )
os windows? R/ [^\\/\\]/ R/ [^\\/]/ ? ; foldable
: wild-path-separator ( -- sep )
os windows? R/ [^\\/\\][\\/\\]|[^\\/\\]/ R/ [^\\/][\\/]|[^\\/]/ ? ; foldable
EBNF: <glob>
Character = "\\" .:c => [[ c 1string <literal> ]]
@ -29,7 +32,8 @@ CharClass = "^"?:n Ranges:e => [[ e <or> n [ <not> ] when ]]
AlternationBody = Concatenation:c "," AlternationBody:a => [[ a c prefix ]]
| Concatenation => [[ 1array ]]
Element = "*" => [[ not-path-separator <zero-or-more> ]]
Element = "**" => [[ wild-path-separator <zero-or-more> ]]
| "*" => [[ not-path-separator <zero-or-more> ]]
| "?" => [[ not-path-separator ]]
| "[" CharClass:c "]" => [[ c ]]
| "{" AlternationBody:b "}" => [[ b <or> ]]