diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2023-11-25 14:57:19 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2023-11-25 14:57:19 -0500 |
| commit | e6e482054de77f3fe5d65344da86065373cf5f23 (patch) | |
| tree | a6876c73bccf490512be5ff93fa808f3ce8d1c95 /tests | |
| parent | e0a55ba6176df325b65b1768bba929805444bf88 (diff) | |
Deprecate '-p' flag and replace backslash interpolation with curly brace
interpolation
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/01-literal.sh | 4 | ||||
| -rw-r--r-- | tests/02-char.sh | 4 | ||||
| -rw-r--r-- | tests/03-char-range.sh | 4 | ||||
| -rw-r--r-- | tests/04-sequence.sh | 4 | ||||
| -rw-r--r-- | tests/05-dot.sh | 4 | ||||
| -rw-r--r-- | tests/06-start-of-line.sh | 4 | ||||
| -rw-r--r-- | tests/07-end-of-line.sh | 4 | ||||
| -rw-r--r-- | tests/08-spaces.sh | 4 | ||||
| -rw-r--r-- | tests/09-ellipsis.sh | 4 | ||||
| -rw-r--r-- | tests/10-words.sh | 4 | ||||
| -rw-r--r-- | tests/11-ordered-choice.sh | 6 | ||||
| -rw-r--r-- | tests/12-star.sh | 4 | ||||
| -rw-r--r-- | tests/13-plus.sh | 4 | ||||
| -rw-r--r-- | tests/14-repeat-sep.sh | 4 | ||||
| -rw-r--r-- | tests/15-repeating.sh | 4 | ||||
| -rw-r--r-- | tests/16-lookahead.sh | 4 | ||||
| -rw-r--r-- | tests/17-lookbehind.sh | 4 | ||||
| -rw-r--r-- | tests/18-lookbehind-variable-length.sh | 4 | ||||
| -rw-r--r-- | tests/19-negation.sh | 4 | ||||
| -rw-r--r-- | tests/20-submatch.sh | 4 | ||||
| -rw-r--r-- | tests/21-no-submatch.sh | 4 | ||||
| -rw-r--r-- | tests/22-replace.sh | 4 | ||||
| -rw-r--r-- | tests/23-nested-parens.sh | 4 | ||||
| -rw-r--r-- | tests/24-backref.sh | 4 | ||||
| -rw-r--r-- | tests/25-replace-capture.sh | 6 | ||||
| -rw-r--r-- | tests/26-null-byte.sh | 2 | ||||
| -rw-r--r-- | tests/27-left-recursion.sh | 2 | ||||
| -rw-r--r-- | tests/28-left-recursion2.sh | 2 | ||||
| -rw-r--r-- | tests/29-left-recursion3.sh | 2 |
29 files changed, 56 insertions, 56 deletions
diff --git a/tests/01-literal.sh b/tests/01-literal.sh index 618dc4b..ddfe1a9 100644 --- a/tests/01-literal.sh +++ b/tests/01-literal.sh @@ -1,3 +1,3 @@ # Use double quotation marks to match literal strings -# Example: bp -p '"baz"' -bp -p '"foo"' +# Example: bp '{ "baz" }' +bp '{ "foo" }' diff --git a/tests/02-char.sh b/tests/02-char.sh index e630e45..1493fa6 100644 --- a/tests/02-char.sh +++ b/tests/02-char.sh @@ -1,3 +1,3 @@ # Match a single character with backtick: -# Example: bp -p '`A' matches the letter "A" -bp -p '`x' +# Example: bp '{`A}' matches the letter "A" +bp '{`x}' diff --git a/tests/03-char-range.sh b/tests/03-char-range.sh index 7904466..36ae483 100644 --- a/tests/03-char-range.sh +++ b/tests/03-char-range.sh @@ -1,3 +1,3 @@ # Character sets and ranges work with backticks -# Example: bp -p '`a-z,A-Z' matches all lowercase and uppercase letters -bp -p '`0-9,a-f' +# Example: bp '{`a-z,A-Z}' matches all lowercase and uppercase letters +bp '{`0-9,a-f}' diff --git a/tests/04-sequence.sh b/tests/04-sequence.sh index dc61eeb..3d8df71 100644 --- a/tests/04-sequence.sh +++ b/tests/04-sequence.sh @@ -1,5 +1,5 @@ # Multiple patterns in a row represent a sequence. # bp pattern syntax mostly doesn't care about whitespace, so you can have # spaces between patterns if you want, but it's not required. -# Example: bp -p '"foo" `0-9' matches "foo1", "foo2", etc. -bp -p '"one" "two"' +# Example: bp '{"foo" `0-9}' matches "foo1", "foo2", etc. +bp '{"one" "two"}' diff --git a/tests/05-dot.sh b/tests/05-dot.sh index ec5c9e7..c963aed 100644 --- a/tests/05-dot.sh +++ b/tests/05-dot.sh @@ -1,3 +1,3 @@ # The dot matches a single character -# Example: bp -p '.' -bp -p '`a .' +# Example: bp '{.}' +bp '{`a .}' diff --git a/tests/06-start-of-line.sh b/tests/06-start-of-line.sh index c44000e..c8e5504 100644 --- a/tests/06-start-of-line.sh +++ b/tests/06-start-of-line.sh @@ -1,3 +1,3 @@ # ^ matches start of a line -# Example: bp -p '^ "x"' matches lines starting with "x" -bp -p '^ "foo"' +# Example: bp '{^ "x"}' matches lines starting with "x" +bp '{^ "foo"}' diff --git a/tests/07-end-of-line.sh b/tests/07-end-of-line.sh index 4a1e05d..5954c10 100644 --- a/tests/07-end-of-line.sh +++ b/tests/07-end-of-line.sh @@ -1,3 +1,3 @@ # $ matches end of line -# Example: bp -p '"x" $' matches lines ending with "x" -bp -p '"foo" $' +# Example: bp '{"x" $}' matches lines ending with "x" +bp '{"foo" $}' diff --git a/tests/08-spaces.sh b/tests/08-spaces.sh index cc16d96..a6a62c9 100644 --- a/tests/08-spaces.sh +++ b/tests/08-spaces.sh @@ -1,3 +1,3 @@ # The _ pattern matches zero or more spaces/tabs -# Example: bp -p '`= _ "foo"' matches "=foo", "= foo", "= foo", etc. -bp -p '"one" _ "two"' +# Example: bp '{`= _ "foo"}' matches "=foo", "= foo", "= foo", etc. +bp '{"one" _ "two"}' diff --git a/tests/09-ellipsis.sh b/tests/09-ellipsis.sh index 0763fd1..c755ab6 100644 --- a/tests/09-ellipsis.sh +++ b/tests/09-ellipsis.sh @@ -1,3 +1,3 @@ # The ellipsis matches text upto the following pattern, not counting newlines -# Example: bp -p '"/*" .. "*/"' matches "/* blah blah */" or "/**/" -bp -p '"hello" .. "world"' +# Example: bp '{"/*" .. "*/"}' matches "/* blah blah */" or "/**/" +bp '{"hello" .. "world"}' diff --git a/tests/10-words.sh b/tests/10-words.sh index c5f5193..afb064d 100644 --- a/tests/10-words.sh +++ b/tests/10-words.sh @@ -1,3 +1,3 @@ # The | operator matches word edges -# Example: bp -p '|"baz"|' matches the word "baz" -bp '\|foo\|' +# Example: bp '{|"baz"|}' matches the word "baz" +bp '{|}foo{|}' diff --git a/tests/11-ordered-choice.sh b/tests/11-ordered-choice.sh index 277741d..4334643 100644 --- a/tests/11-ordered-choice.sh +++ b/tests/11-ordered-choice.sh @@ -1,5 +1,5 @@ # The ordered choice operator (/) picks the first choice that matches -# Example: bp -p '"cabaret"/"cab"' matches either "cabaret" or "cab" +# Example: bp '{"cabaret"/"cab"}' matches either "cabaret" or "cab" # Note: if a match occurs, the options to the right will *never* be attempted, -# so bp -p '"cab"/"cabaret"' will always match "cab" instead of "cabaret" -bp -p '"foo" / "bar"' +# so bp '{"cab"/"cabaret"}' will always match "cab" instead of "cabaret" +bp '{"foo" / "bar"}' diff --git a/tests/12-star.sh b/tests/12-star.sh index bd2d578..f0a9de9 100644 --- a/tests/12-star.sh +++ b/tests/12-star.sh @@ -1,3 +1,3 @@ # The star (*) prefix operator matches zero or more repetitions -# Example: bp -p '"Ha" *"ha"' will match "Ha", "Haha", "Hahaha", etc. -bp -p '`( *`x `)' +# Example: bp '{"Ha" *"ha"}' will match "Ha", "Haha", "Hahaha", etc. +bp '{`( *`x `)}' diff --git a/tests/13-plus.sh b/tests/13-plus.sh index c2aa7cc..7ac39e7 100644 --- a/tests/13-plus.sh +++ b/tests/13-plus.sh @@ -1,3 +1,3 @@ # The plus (+) prefix operator matches one or more of a pattern -# Example: bp -p '"l" +"ol"' will match "lol", "lolol", "lololol", etc. -bp -p '`( +`x `)' +# Example: bp '{"l" +"ol"}' will match "lol", "lolol", "lololol", etc. +bp '{`( +`x `)}' diff --git a/tests/14-repeat-sep.sh b/tests/14-repeat-sep.sh index 879ec4b..f61a4bc 100644 --- a/tests/14-repeat-sep.sh +++ b/tests/14-repeat-sep.sh @@ -1,3 +1,3 @@ # The '%' operator modifies repeating patterns, allowing you to give a separator between matches -# Example: bp -p '+"x" % ":"' will match "x", "x:x", "x:x:x", etc. -bp -p '`( +int % `, `)' +# Example: bp '{+"x" % ":"}' will match "x", "x:x", "x:x:x", etc. +bp '{`( +int % `, `)}' diff --git a/tests/15-repeating.sh b/tests/15-repeating.sh index 115e791..7672195 100644 --- a/tests/15-repeating.sh +++ b/tests/15-repeating.sh @@ -1,3 +1,3 @@ # Numbers allow you to specify repetitions of a pattern -# Example: bp -p '3 "x"' matches "xxx" -bp -p '`( 4 . `)' +# Example: bp '{3 "x"}' matches "xxx" +bp '{`( 4 . `)}' diff --git a/tests/16-lookahead.sh b/tests/16-lookahead.sh index 18761bd..4b8d5f8 100644 --- a/tests/16-lookahead.sh +++ b/tests/16-lookahead.sh @@ -1,3 +1,3 @@ # >pat is a lookahead -# Example: bp -p '"foo" >`(' will match "foo" only when it is followed by a parenthesis -bp -p '>`t word' +# Example: bp '{"foo" >`(}' will match "foo" only when it is followed by a parenthesis +bp '{>`t word}' diff --git a/tests/17-lookbehind.sh b/tests/17-lookbehind.sh index 0b5136a..fe14678 100644 --- a/tests/17-lookbehind.sh +++ b/tests/17-lookbehind.sh @@ -1,3 +1,3 @@ # <pat is a lookbehind -# Example: bp -p '<`: word' will match words that come after a colon -bp -p '<`2 `3' +# Example: bp '{<`: word}' will match words that come after a colon +bp '{<`2 `3}' diff --git a/tests/18-lookbehind-variable-length.sh b/tests/18-lookbehind-variable-length.sh index 851c549..d41a708 100644 --- a/tests/18-lookbehind-variable-length.sh +++ b/tests/18-lookbehind-variable-length.sh @@ -1,3 +1,3 @@ # Lookbehinds can have variable length. -# Example: bp -p '<(^ +`# _) "foo"' matches lines starting with "# foo", "## foo", "### foo", etc. -bp -p '<(`U +`h "...") "ok"' +# Example: bp '{<(^ +`# _) "foo"}' matches lines starting with "# foo", "## foo", "### foo", etc. +bp '{<(`U +`h "...") "ok"}' diff --git a/tests/19-negation.sh b/tests/19-negation.sh index 2928df1..2fbb11c 100644 --- a/tests/19-negation.sh +++ b/tests/19-negation.sh @@ -1,3 +1,3 @@ # !pat matches only if pat doesn't match -# Example: bp -p '"cat" !"aclysm"' matches the "cat" in "catatonic", but not "cataclysm" -bp -p '"foo" !"bar"' +# Example: bp '"cat" !"aclysm"' matches the "cat" in "catatonic", but not "cataclysm" +bp '{"foo" !"bar"}' diff --git a/tests/20-submatch.sh b/tests/20-submatch.sh index 22da9e0..5543fcf 100644 --- a/tests/20-submatch.sh +++ b/tests/20-submatch.sh @@ -1,3 +1,3 @@ # pat1 ~ pat2 matches if pat2 can be found within pat1, like words containing "e" -# Example: bp -p '+`0-9 ~ `5' matches "12345" and "72581", but not "789" -bp -p 'word ~ `e' +# Example: bp '{+`0-9 ~ `5}' matches "12345" and "72581", but not "789" +bp '{word ~ `e}' diff --git a/tests/21-no-submatch.sh b/tests/21-no-submatch.sh index c187694..8bb418d 100644 --- a/tests/21-no-submatch.sh +++ b/tests/21-no-submatch.sh @@ -1,3 +1,3 @@ # pat1 !~ pat2 matches if pat2 cannot be found within pat1, like words *not* containing "e" -# Example: bp -p '(|+`0-9|) !~ `5' matches "123" and "678", but not "456" -bp -p 'word !~ `e' +# Example: bp '{(|+`0-9|) !~ `5}' matches "123" and "678", but not "456" +bp '{word !~ `e}' diff --git a/tests/22-replace.sh b/tests/22-replace.sh index cd48850..451be8f 100644 --- a/tests/22-replace.sh +++ b/tests/22-replace.sh @@ -1,3 +1,3 @@ # Replacements can be done with pat => "replacement" -# Example: bp -p '"foo" => "baz"' matches "foobar" and replaces it with "bazbar" -bp -p '"s" => "$"' +# Example: bp '{"foo" => "baz"}' matches "foobar" and replaces it with "bazbar" +bp '{"s" => "$"}' diff --git a/tests/23-nested-parens.sh b/tests/23-nested-parens.sh index 1bf872e..6b3c01b 100644 --- a/tests/23-nested-parens.sh +++ b/tests/23-nested-parens.sh @@ -1,3 +1,3 @@ # parens is a pattern matching nested parentheses -# Example: bp -p '"foo" parens' matches "foo()" or "foo(baz(), qux())", but not "foo(()" -bp -p 'id parens `;' +# Example: bp '{"foo" parens}' matches "foo()" or "foo(baz(), qux())", but not "foo(()" +bp '{id parens `;}' diff --git a/tests/24-backref.sh b/tests/24-backref.sh index 28a203b..2a7d89b 100644 --- a/tests/24-backref.sh +++ b/tests/24-backref.sh @@ -1,3 +1,3 @@ # With @-capturing, you can reference previous captures -# Example: bp -p '@first=`a-z .. first' matches "aba" and "xyzx", but not "abc" -bp -p '@first:+Abc _ +Abc _ first' +# Example: bp '{@first=`a-z .. first}' matches "aba" and "xyzx", but not "abc" +bp '{@first:+Abc _ +Abc _ first}' diff --git a/tests/25-replace-capture.sh b/tests/25-replace-capture.sh index f401605..70fc889 100644 --- a/tests/25-replace-capture.sh +++ b/tests/25-replace-capture.sh @@ -1,4 +1,4 @@ # Captures with @ can be referenced in a replacement by @1, @2, etc. -# Example: bp -p '"=" _ @+`0-9 => "= -@1"' replaces "x = 5" with "x = -5" -# Note: @0 refers to the entire match, e.g. bp -p '"foo" => "xx@0xx"' replaces "foo" with "xxfooxx" -bp -p '@`a,e,i,o,u => "{@1}" / .' +# Example: bp '{"=" _ @+`0-9 => "= -@1"}' replaces "x = 5" with "x = -5" +# Note: @0 refers to the entire match, e.g. bp '{"foo" => "xx@0xx"}' replaces "foo" with "xxfooxx" +bp '{@`a,e,i,o,u => "{@1}" / .}' diff --git a/tests/26-null-byte.sh b/tests/26-null-byte.sh index 2c825c3..84996a8 100644 --- a/tests/26-null-byte.sh +++ b/tests/26-null-byte.sh @@ -1,2 +1,2 @@ # Null bytes can be matched with \x00 -bp -p '\x00' +bp '{\x00}' diff --git a/tests/27-left-recursion.sh b/tests/27-left-recursion.sh index ec11cab..3472fb6 100644 --- a/tests/27-left-recursion.sh +++ b/tests/27-left-recursion.sh @@ -1,2 +1,2 @@ # Left recursion should work -bp -p 'xys: (xys / `x) `y; xys => "{@0}"' +bp '{xys: (xys / `x) `y; xys => "{@0}"}' diff --git a/tests/28-left-recursion2.sh b/tests/28-left-recursion2.sh index 995f82c..e348340 100644 --- a/tests/28-left-recursion2.sh +++ b/tests/28-left-recursion2.sh @@ -1,2 +1,2 @@ # Left recursion has some tricky edge cases like this: -bp -p 'foo: (foo / `a-z) (foo / `a-z) `!; foo => "{@0}"' +bp '{foo: (foo / `a-z) (foo / `a-z) `!; foo => "{@0}"}' diff --git a/tests/29-left-recursion3.sh b/tests/29-left-recursion3.sh index 7de7379..936ca78 100644 --- a/tests/29-left-recursion3.sh +++ b/tests/29-left-recursion3.sh @@ -1,2 +1,2 @@ # Left recursion has some tricky edge cases like this: -bp -p 'shout: phrase `!; phrase: shout / id; phrase => "{@0}"' +bp '{shout: phrase `!; phrase: shout / id; phrase => "{@0}"}' |
