diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2020-09-28 16:35:22 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2020-09-28 16:35:22 -0700 |
| commit | 907101b42159c3d2a8ee74540fb8e9259b36db7e (patch) | |
| tree | 7f988fd069c4eb445ea89d191dc551086c1fce71 /grammars | |
| parent | 5049bd7cad8478ecb3f16f8aa7b9b741825922d7 (diff) | |
Fixes for captures and backrefs, and added block comments
Diffstat (limited to 'grammars')
| -rw-r--r-- | grammars/bpeg.bpeg | 7 | ||||
| -rw-r--r-- | grammars/builtins.bpeg | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/grammars/bpeg.bpeg b/grammars/bpeg.bpeg index 380bf9c..88dc6b1 100644 --- a/grammars/bpeg.bpeg +++ b/grammars/bpeg.bpeg @@ -49,7 +49,7 @@ Repeat: ( Optional: `[ __ extended-pat (__`] / @!={=> "Expected closing square bracket here"}) After: `< _ pat Before: `> _ pat -Capture: `@ [_ `[ @capture-name=(...>(`]/$$)) (`] / @!={=>"Expected closing bracket here"})] _ @capture=pat +Capture: `@ [_ @capture-name=(id/`!) !"=>" `=] _ (@capture=pat / @!={=> "Expected pattern to capture"}) Replace: `{ __ ( [@replace-pat=extended-pat __] "=>" [__ @replacement=String] ) __ (`} / @!={=> "Expected closing brace here"}) @@ -71,7 +71,8 @@ $: !. id: "^^" / "^" / "__" / "_" / "$$" / "$" / (`a-z/`A-Z) 0+(`a-z/`A-Z/`0-9/`-) -hash-comment: `# .. $ +line-comment: `# .. $ +block-comment: "#(" 0+(block-comment / !")#" .) ")#" # Note: comments are undefined by default in regular BPEG -comment: hash-comment +comment: block-comment / line-comment diff --git a/grammars/builtins.bpeg b/grammars/builtins.bpeg index 1633a30..c05b4c7 100644 --- a/grammars/builtins.bpeg +++ b/grammars/builtins.bpeg @@ -30,7 +30,7 @@ only-matches: ( (include-binary-files / is-text-file) define-highlights add-filename - 1+{...@hl-pattern=>'@1\n'} + 1+{...@hl-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 "} / {=>"@#| "})] |
