From e6e482054de77f3fe5d65344da86065373cf5f23 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 25 Nov 2023 14:57:19 -0500 Subject: Deprecate '-p' flag and replace backslash interpolation with curly brace interpolation --- tests/01-literal.sh | 4 ++-- tests/02-char.sh | 4 ++-- tests/03-char-range.sh | 4 ++-- tests/04-sequence.sh | 4 ++-- tests/05-dot.sh | 4 ++-- tests/06-start-of-line.sh | 4 ++-- tests/07-end-of-line.sh | 4 ++-- tests/08-spaces.sh | 4 ++-- tests/09-ellipsis.sh | 4 ++-- tests/10-words.sh | 4 ++-- tests/11-ordered-choice.sh | 6 +++--- tests/12-star.sh | 4 ++-- tests/13-plus.sh | 4 ++-- tests/14-repeat-sep.sh | 4 ++-- tests/15-repeating.sh | 4 ++-- tests/16-lookahead.sh | 4 ++-- tests/17-lookbehind.sh | 4 ++-- tests/18-lookbehind-variable-length.sh | 4 ++-- tests/19-negation.sh | 4 ++-- tests/20-submatch.sh | 4 ++-- tests/21-no-submatch.sh | 4 ++-- tests/22-replace.sh | 4 ++-- tests/23-nested-parens.sh | 4 ++-- tests/24-backref.sh | 4 ++-- tests/25-replace-capture.sh | 6 +++--- tests/26-null-byte.sh | 2 +- tests/27-left-recursion.sh | 2 +- tests/28-left-recursion2.sh | 2 +- tests/29-left-recursion3.sh | 2 +- 29 files changed, 56 insertions(+), 56 deletions(-) (limited to 'tests') 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 @@ # "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}"}' -- cgit v1.2.3