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/bpeg.bpeg | |
| parent | 6e1fd928148cc7e46015e06c27f824d4111f96ee (diff) | |
Bunch of changes, including some bpeg->bp renaming, and adding
visualizations
Diffstat (limited to 'grammars/bpeg.bpeg')
| -rw-r--r-- | grammars/bpeg.bpeg | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/grammars/bpeg.bpeg b/grammars/bpeg.bpeg deleted file mode 100644 index 288ceee..0000000 --- a/grammars/bpeg.bpeg +++ /dev/null @@ -1,78 +0,0 @@ -# This is a file defining the BPEG grammar using BPEG syntax - -Grammar: __ *(Def [__`;])%__ __ ($$ / @!={... => "Could not parse this code"}) -Def: @name=id _ `: __ ( - @definition=extended-pat - / $$ @!={=>"No definition for rule"} - / @!={...>(`;/id_`:/$) => "Invalid definition: @0"}) - -# This is used for command line arguments: -String-pattern: *(`\ (escape-sequence / pat [`;]) / .) - -pat: simple-pat !(__("!="/"==")) / suffixed-pat -simple-pat: Upto-and / Dot / String / Char-range / Char / Escape-range / Escape / No - / Nodent / Repeat / Optional / After / Before / Capture / Replace / Ref / parens - -suffixed-pat: ( - Eq-pat - / Not-eq-pat -) - -Eq-pat: @first=pat__"=="__@second=pat -Not-eq-pat: @first=pat__"!="__@second=pat - -Dot: `. !`. -String: ( - `" @s=*(Escape / !`".) (`" / @!={=> "Expected closing quote here"}) - / `' @s=*(Escape / !`'.) (`' / @!={=> "Expected closing quote here"}) - ) -Char-range: `` @low=. `- (@high=. / @!={=> "Expected a second character to form a character range"}) -Char: `` (@s=. / @!={=> "Expected a character following the '`'"}) -Escape-range: `\ @low=escape-sequence `- @high=escape-sequence -Escape: `\ (@s=escape-sequence - / $ @!={=>"Backslashes are used for escape sequences, not splitting lines"} - / @!={. *(Abc/`0-9) => "Invalid escape sequence: '@0'"} -) -escape-sequence: ( - `n/`t/`r/`e/`b/`a/`v - / 1-3 `0-7 - / `x 2 (`0-9/`a-f/`A-F) - ) -No: `! (_@pat / @!={=>"Expected a pattern after the exclamation mark"}) -Nodent: `| -Upto-and: 2-3`. [_@simple-pat] -Repeat: ( - @min=int _ `- _ @max=int - / @min=int _ `+ @max='' - / @min=@max=int - ) __ @repeat-pat=pat [__`%__@sep=pat] -Optional: `[ __ extended-pat (__`] / @!={=> "Expected closing square bracket here"}) -After: `< _ pat -Before: `> _ pat -Capture: `@ [_ @capture-name=(id/`!) __ !"=>" `=] __ (@capture=pat / @!={=> "Expected pattern to capture"}) -Replace: `{ __ ( - [@replace-pat=extended-pat __] "=>" [__ @replacement=String] - ) __ (`} / @!={=> "Expected closing brace here"}) -Ref: @name=id !(_`:) - -parens: `( __ extended-pat (__ `) / @!={=> "Expected closing parenthesis here"}) - -Chain: 2+@pat%__ -Otherwise: 2+@(Chain/pat)%(__`/__) -extended-pat: Otherwise / Chain / pat - -# Special-symbol rules: -_: *(` / \t) -__: *(` / \t / \r / \n / comment) -$$: !$. -$: !. -^^: !<$. -^: !<. - -id: "^^" / "^" / "__" / "_" / "$$" / "$" / (`a-z/`A-Z) *(`a-z/`A-Z/`0-9/`-) - -line-comment: `# .. $ -block-comment: "#(" *(block-comment / !")#" .) ")#" - -# Note: comments are undefined by default in regular BPEG -comment: block-comment / line-comment |
