diff options
| -rw-r--r-- | grammars/builtins.bpeg | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/grammars/builtins.bpeg b/grammars/builtins.bpeg index 4b200a9..4b8c07b 100644 --- a/grammars/builtins.bpeg +++ b/grammars/builtins.bpeg @@ -7,7 +7,7 @@ replacement = !(/); # Not defined by default replace-all = add-filename 1+(...@hl-replacement) ...; find-all = add-filename 1+find-next%\n 0-1{!<\n => "\n"}; find-next = matching-line / {..\n =>} find-next; -only-matches = 1+{...hl-pattern=>'@1\n'}; +only-matches = 1+{...@hl-pattern=>'@1\n'}; matching-line = add-line-number 1+(..hl-pattern) ..$; is-tty = no; # Defined as either always-match or always-fail, depending on stdout @@ -16,9 +16,9 @@ print-filenames = is-tty; add-filename = 0-1(print-filenames (is-tty {=>"\033[33;1;4m@&:\033[0m\n"} / {=>"@&:\n"})); add-line-number = 0-1(print-line-numbers (is-tty {=>"\033[2m@#\033[5G|\033[0m "} / {=>"@#| "})); highlight-matches = is-tty; -hl-pattern = { @pattern @0-1{highlight-matches => "\033[1;31m"} @0-1{highlight-matches => "\033[0m"} => "@2@1@3" }; +hl-pattern = {@[match]pattern (highlight-matches @{=>"\033[1;31m"} @{=>"\033[0m"} / @"" @"") => "@2@1@3"}; highlight-replacements = is-tty; -hl-replacement = { @replacement @0-1{highlight-replacements => "\033[1;35m"} @0-1{highlight-replacements => "\033[0m"} => "@2@1@3" }; +hl-replacement = { @replacement (highlight-replacements @{=>"\033[1;35m"} @{=>"\033[0m"} / @"" @"") => "@2@1@3" }; # Helper definitions (commonly used) indent = \n|1+(\t/' '); @@ -31,6 +31,7 @@ brackets = `[ 0+(brackets / !`].) `]; braces = `{ 0+(braces / !`}.) `}; parens = `( 0+(parens / !`).) `); id = !<(`a-z/`A-Z/`_/`0-9) (`a-z/`A-Z/`_) 0+(`a-z/`A-Z/`_/`0-9); +id-char = `a-z/`A-Z/`_/`0-9; word = !<(`a-z/`A-Z/`_/`0-9) 1+(`a-z/`A-Z) !>(`0-9/`_); HEX = `0-9/`A-F; Hex = `0-9/`a-f/`A-F; |
