aboutsummaryrefslogtreecommitdiff
path: root/grammars
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-05-10 23:46:46 -0700
committerBruce Hill <bruce@bruce-hill.com>2021-05-10 23:46:46 -0700
commit17dbe5d9e8fcbe2c5f2f494658868b28857a25ca (patch)
treeb5fafea0caac649ab93c273e1d81f476a13624fc /grammars
parent943aa0b71a8c2a03fe4b57317d4c7bc7df7d014c (diff)
Added {word} feature and cleaned up the code some.
Diffstat (limited to 'grammars')
-rw-r--r--grammars/bp.bp5
-rw-r--r--grammars/c++.bp4
-rw-r--r--grammars/c.bp4
-rw-r--r--grammars/go.bp4
-rw-r--r--grammars/javascript.bp4
-rw-r--r--grammars/lisp.bp2
-rw-r--r--grammars/lua.bp6
-rw-r--r--grammars/python.bp6
-rw-r--r--grammars/rust.bp4
9 files changed, 20 insertions, 19 deletions
diff --git a/grammars/bp.bp b/grammars/bp.bp
index 725d213..6d98187 100644
--- a/grammars/bp.bp
+++ b/grammars/bp.bp
@@ -29,8 +29,9 @@ Not-eq-pat: @first=(suffixed-pat / simple-pat)__"!="__@second=pat
Dot: `. !`.
String: (
- `" @s=*(Escape / !`".) (`" / @!=(''=> "Expected closing quote here"))
- / `' @s=*(Escape / !`'.) (`' / @!=(''=> "Expected closing quote here"))
+ `" @s=.. (`" / $ @!=(''=> "Expected closing quote here"))
+ / `' @s=.. (`' / $ @!=(''=> "Expected closing quote here"))
+ / `{ @s=.. (`} / $ @!=(''=> "Expected closing brace here"))
)
Chars: `` @+(Char-range/Char) % `,
Char-range: @low=. `- (@high=. / @!=(''=> "Expected a second character to form a character range"))
diff --git a/grammars/c++.bp b/grammars/c++.bp
index e8be4db..33e3fb7 100644
--- a/grammars/c++.bp
+++ b/grammars/c++.bp
@@ -25,5 +25,5 @@ keyword: |(
)|
function-def: ^_ 2+(keyword / id / anglebraces / `*) % __ parens (__`; / >(__`{))
function: function-def __ braces
-macro: ^"#define " ..$ *(<`\ \n..$)
-import: ^("#include"/"#import")| __ (string / `<..`>)
+macro: ^{#define} ..$ *(<`\ \n..$)
+import: ^({#include}/{#import}) __ (string / `<..`>)
diff --git a/grammars/c.bp b/grammars/c.bp
index e472a02..be91cbe 100644
--- a/grammars/c.bp
+++ b/grammars/c.bp
@@ -17,5 +17,5 @@ keyword: |(
)|
function-def: ^_ 2+(keyword / id / `*) % __ parens (__`; / >(__`{))
function: function-def __ braces
-macro: ^"#define " ..$ *(<`\ \n..$)
-import: ^"#include"| __ (string / `<..`>)
+macro: ^{#define} ..$ *(<`\ \n..$)
+import: ^{#include} __ (string / `<..`>)
diff --git a/grammars/go.bp b/grammars/go.bp
index 01f983f..425325a 100644
--- a/grammars/go.bp
+++ b/grammars/go.bp
@@ -13,6 +13,6 @@ keyword: |(
"map" / "struct" / "chan" / "else" / "goto" / "package" / "switch" / "const" /
"fallthrough" / "if" / "range" / "type" / "continue" / "for" / "import" / "return" / "var"
)|
-function-def: |"func"| __ id __ parens __ [id / parens] >(__`{)
+function-def: {func} __ id __ parens __ [id / parens] >(__`{)
function: function-def __ braces
-import: |"import"| __ (parens / string)
+import: {import} __ (parens / string)
diff --git a/grammars/javascript.bp b/grammars/javascript.bp
index fa5c8d3..b663050 100644
--- a/grammars/javascript.bp
+++ b/grammars/javascript.bp
@@ -19,6 +19,6 @@ keyword: |(
"this" / "throw" / "throws" / "transient" / "true" / "try" / "typeof" / "var" /
"void" / "volatile" / "while" / "with" / "yield"
)|
-function-def: |"function"| __ [id__] parens / (id / parens) __ "=>"
+function-def: {function} __ [id__] parens / (id / parens) __ "=>"
function: function-def __ braces
-import: |"import"| ..%braces (`; / $)
+import: {import} ..%braces (`; / $)
diff --git a/grammars/lisp.bp b/grammars/lisp.bp
index 25e2312..3e1f4dc 100644
--- a/grammars/lisp.bp
+++ b/grammars/lisp.bp
@@ -9,7 +9,7 @@
comment: ";" ..$
string: `" ..%(`\.) `"
list: parens
-function-def: `(__"defun"|__id
+function-def: `(__{defun}__id
function: function-def ..%parens `)
id-char: `A-Z,a-z,0-9,!,$,%,&,*,+,-,.,/,:,<,=,>,?,@,^,_,~
id: !<`A-Z,a-z,0-9,!,$,%,&,*,+,-,.,/,:,<,=,>,?,@,^,_,~ +`A-Z,a-z,0-9,!,$,%,&,*,+,-,.,/,:,<,=,>,?,@,^,_,~
diff --git a/grammars/lua.bp b/grammars/lua.bp
index e8c9ba8..5554167 100644
--- a/grammars/lua.bp
+++ b/grammars/lua.bp
@@ -14,6 +14,6 @@ keyword: |(
"function" / "goto" / "if" / "in" / "local" / "nil" / "not" / "or" /
"repeat" / "return" / "then" / "true" / "until" / "while"
)|
-function-def: |"function"|[_id (*(`.id)[`:id])]_ parens
-block: function / |("do"/"then")| ..%(comment/string/block/\n) (|"end"|)
-function: function-def ..%(comment/string/block/\n) (|"end"|)
+function-def: {function}[_id (*(`.id)[`:id])]_ parens
+block: function / ({do}/{then}) ..%(comment/string/block/\n) {end}
+function: function-def ..%(comment/string/block/\n) {end}
diff --git a/grammars/python.bp b/grammars/python.bp
index 13c9251..daab6a5 100644
--- a/grammars/python.bp
+++ b/grammars/python.bp
@@ -14,7 +14,7 @@ keyword: |("and" / "as" / "assert" / "break" / "class" / "continue" / "def" /
"not" / "or" / "pass" / "raise" / "return" / "try" / "while" /
"with" / "yield")|
class: class-def +(\N ..$)
-class-def: ^_|"class"|_id[_parens]_`:
+class-def: ^_{class}_id[_parens]_`:
function: function-def +(\N ..$)
-function-def: ^_|"def"|_id parens `:
-import: ^_["from"| ..%parens >(|"import"|)] |"import"| ..%parens $
+function-def: ^_{def}_id parens `:
+import: ^_[{from} ..%parens >{import}] {import} ..%parens $
diff --git a/grammars/rust.bp b/grammars/rust.bp
index 3585732..bb58a61 100644
--- a/grammars/rust.bp
+++ b/grammars/rust.bp
@@ -14,6 +14,6 @@ keyword: |(
"mod" / "move" / "mut" / "pub" / "ref" / "return" / "self" / "Self" / "static" /
"struct" / "super" / "trait" / "true" / "type" / "unsafe" / "use" / "where" / "while"
)|
-function-def: |"fn"| __ id __ parens __ ["->"__(id / parens)] >(__`{)
+function-def: {fn} __ id __ parens __ ["->"__(id / parens)] >(__`{)
function: function-def __ braces
-import: |"use"| _ *(id / braces) % "::" _ `;
+import: {use} _ *(id / braces) % "::" _ `;