diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2020-12-12 16:31:53 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2020-12-12 16:31:53 -0800 |
| commit | eb329bdac9fe56d67cb130fb6cdbb28743c6504b (patch) | |
| tree | 8ba8bded07820519de06728618e4e32e80da3af4 /grammars | |
| parent | 6e1fd928148cc7e46015e06c27f824d4111f96ee (diff) | |
Bunch of changes, including some bpeg->bp renaming, and adding
visualizations
Diffstat (limited to 'grammars')
| -rw-r--r-- | grammars/bpeg.bp (renamed from grammars/bpeg.bpeg) | 0 | ||||
| -rw-r--r-- | grammars/builtins.bp (renamed from grammars/builtins.bpeg) | 23 | ||||
| -rw-r--r-- | grammars/html.bp (renamed from grammars/html.bpeg) | 0 | ||||
| -rw-r--r-- | grammars/utf8-id.bp (renamed from grammars/utf8-id.bpeg) | 0 |
4 files changed, 5 insertions, 18 deletions
diff --git a/grammars/bpeg.bpeg b/grammars/bpeg.bp index 288ceee..288ceee 100644 --- a/grammars/bpeg.bpeg +++ b/grammars/bpeg.bp diff --git a/grammars/builtins.bpeg b/grammars/builtins.bp index 697bf27..7de936f 100644 --- a/grammars/builtins.bpeg +++ b/grammars/builtins.bp @@ -3,9 +3,6 @@ no: !'' # Configurable options: is-tty: no # Defined as either always-match or always-fail, depending on stdout -print-line-numbers: is-tty -print-filenames: is-tty -highlight: is-tty include-binary-files: no; is-text-file: ^^ >32(\t/\n/\r/\x20-x7e/!\x00-x7f utf8-codepoint/$$) @@ -14,29 +11,18 @@ pattern: !'' # Not defined by default replacement: !'' # Not defined by default replace-all: ( (include-binary-files / is-text-file) - define-highlights - add-filename - *(...(>pattern hl-replacement)) ... + +(...(>pattern replacement)) ... ) find-all: ( (include-binary-files / is-text-file) - define-highlights - add-filename - *(!..pattern {..\n=>}) - +(>..pattern add-line-number +(..hl-pattern) ..(\n/$$) / {..\n=>}) + *(!..pattern ~(..\n)) + +(+(..@pattern) ..(\n/$$) / ~(..\n)) [{!<\n => "\n"}] ) only-matches: ( (include-binary-files / is-text-file) - define-highlights - add-filename - +{...@hl-pattern =>'@1\n'} + +{...@pattern =>'@1\n'} ) -add-filename: [print-filenames (is-tty {=>"\033[33;1;4m@&:\033[0m\n"} / {=>"@&:\n"})] -add-line-number: [print-line-numbers (is-tty {=>"\033[2m@#\033[5G|\033[0m "} / {=>"@#| "})] -hl-pattern: {@match=pattern define-highlights => "@hl-start;@match;@hl-end;"} -hl-replacement: {@match=replacement define-highlights => "@hl-start;@match;@hl-end;" } -define-highlights: highlight @hl-start={=>"\033[31;1m"} @hl-end={=>"\033[0m"} / @hl-start="" @hl-end="" # Helper definitions (commonly used) url: ( @@ -70,6 +56,7 @@ parens: `( *(parens / $. != `)) `) id: !<(`a-z/`A-Z/`_/`0-9) (`a-z/`A-Z/`_) *(`a-z/`A-Z/`_/`0-9) id-char: `a-z/`A-Z/`_/`0-9 word: !<(`a-z/`A-Z/`_/`0-9) +(`a-z/`A-Z) !>(`0-9/`_) +edge: !<(`a-z/`A-Z/`_/`0-9) / !>(`0-9/`_) HEX: `0-9/`A-F Hex: `0-9/`a-f/`A-F hex: `0-9/`a-f diff --git a/grammars/html.bpeg b/grammars/html.bp index cea19c1..cea19c1 100644 --- a/grammars/html.bpeg +++ b/grammars/html.bp diff --git a/grammars/utf8-id.bpeg b/grammars/utf8-id.bp index 26e98ba..26e98ba 100644 --- a/grammars/utf8-id.bpeg +++ b/grammars/utf8-id.bp |
