diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2022-05-12 12:11:28 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2022-05-12 12:11:28 -0400 |
| commit | 56da250d69615d70774dbc361fa2693cca1e3df4 (patch) | |
| tree | dbdeb2be018c5f10c13f721965b3bebff2283e88 /grammars | |
| parent | e484a888151460ffc25a8478d9a9c9836652a35c (diff) | |
Split backref/named captures into separate concepts for performance
reasons.
Diffstat (limited to 'grammars')
| -rw-r--r-- | grammars/bp.bp | 4 | ||||
| -rw-r--r-- | grammars/html.bp | 4 | ||||
| -rw-r--r-- | grammars/lua.bp | 4 | ||||
| -rw-r--r-- | grammars/shell.bp | 2 |
4 files changed, 7 insertions, 7 deletions
diff --git a/grammars/bp.bp b/grammars/bp.bp index 2782934..a77881b 100644 --- a/grammars/bp.bp +++ b/grammars/bp.bp @@ -6,7 +6,7 @@ # language grammars. Grammar: __ *(Def [__`;])%__ __ [@error=(+(./\n) => "Could not parse this code: @0")] -Def: @name=id __ `: __ ( +Def: @name=id __ 1-2`: __ ( @definition=extended-pat / $$ @error=(=>"No definition for rule") / @error=(..%\n>(`;/id_`:/$) => "Invalid definition: @0")) @@ -62,7 +62,7 @@ Repeat: ( Optional: `[ __ extended-pat (__`] / @error=(=>"Expected closing square bracket here")) After: `< __ pat Before: `> __ pat -Capture: `@ [__ @capture-name=(id/`!) __ !"=>" `=] __ (@capture=pat / @error=(=>"Expected pattern to capture")) +Capture: `@ [__ @capture-name=(id/`!) __ !"=>" `=,:] __ (@capture=pat / @error=(=>"Expected pattern to capture")) Replace: ( @replace-pat=[Chain-noreplace / pat] __ "=>" (__ @replacement=String / @error=(=>"Expected replacement string")) ) diff --git a/grammars/html.bp b/grammars/html.bp index 1ed83df..1000670 100644 --- a/grammars/html.bp +++ b/grammars/html.bp @@ -14,9 +14,9 @@ void-element: `< ("area"/"base"/"br"/"col"/"embed"/"hr"/"img"/"input"/"link"/"me template-element: "<template>" ..%(\n / comment / element) "</template>" -raw-element: `< @tag=("script"/"style"/"textarea"/"title") __attributes__ `> ..%\n ("</"tag__`>) +raw-element: `< @tag:("script"/"style"/"textarea"/"title") __attributes__ `> ..%\n ("</"tag__`>) -normal-element: `< @tag=id __attributes__ `> ..%(\n / comment / element) ("</"tag__`>) +normal-element: `< @tag:id __attributes__ `> ..%(\n / comment / element) ("</"tag__`>) comment: "<!--" ..%\n "-->" diff --git a/grammars/lua.bp b/grammars/lua.bp index 3d3b862..4f417d2 100644 --- a/grammars/lua.bp +++ b/grammars/lua.bp @@ -6,8 +6,8 @@ # full parse tree, and having one makes the task considerably more complicated. # See the accompanying README.md for more info. -comment: "--" (`[ @eqs=*`= `[ ..%\n (`]eqs`]) / ..$) -string: `"..%string-escape `" / `' ..%string-escape `' / `[ @eqs=*`= `[ ..%\n (`]eqs`]) +comment: "--" (`[ @eqs:*`= `[ ..%\n (`]eqs`]) / ..$) +string: `"..%string-escape `" / `' ..%string-escape `' / `[ @eqs:*`= `[ ..%\n (`]eqs`]) table: `{ ..%(table/string/comment/\n) `} keyword: ("and" / "break" / "do" / "else" / "elseif" / "end" / "false" / "for" / "function" / "goto" / "if" / "in" / "local" / "nil" / "not" / "or" / diff --git a/grammars/shell.bp b/grammars/shell.bp index 76cdcfa..d305d6c 100644 --- a/grammars/shell.bp +++ b/grammars/shell.bp @@ -7,7 +7,7 @@ # See the accompanying README.md for more info. comment: `#..$ -string: `" ..%(string-escape / subcommand / \n) `" / `' ..%\n `' / "<<" _ @delim=id _$ ..%\n (^delim$) +string: `" ..%(string-escape / subcommand / \n) `" / `' ..%\n `' / "<<" _ @delim:id _$ ..%\n (^delim$) string-escape: `\ `",` subcommand: `` ..%\n `` / "$" (parens/braces) keyword: ("echo" / "read" / "set" / "unset" / "readonly" / "shift" / "export" / "if" / "fi" / |
