aboutsummaryrefslogtreecommitdiff
path: root/grammars
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-05-19 21:58:54 -0700
committerBruce Hill <bruce@bruce-hill.com>2021-05-19 21:58:54 -0700
commit5d5817c2a3d21e91db4eaaf607ff881d71b57638 (patch)
treec147550067d237a8d45c35870e18ea4957772c0b /grammars
parent6ff7a6753032bc41098042258096bde73ed4bd1c (diff)
Fancier string escape sequences and a bit of cleanup.
Diffstat (limited to 'grammars')
-rw-r--r--grammars/builtins.bp3
-rw-r--r--grammars/c++.bp2
-rw-r--r--grammars/c.bp3
-rw-r--r--grammars/go.bp2
-rw-r--r--grammars/javascript.bp2
-rw-r--r--grammars/lisp.bp2
-rw-r--r--grammars/lua.bp2
-rw-r--r--grammars/python.bp2
-rw-r--r--grammars/rust.bp2
-rw-r--r--grammars/shell.bp5
10 files changed, 14 insertions, 11 deletions
diff --git a/grammars/builtins.bp b/grammars/builtins.bp
index 8119573..6c0fc75 100644
--- a/grammars/builtins.bp
+++ b/grammars/builtins.bp
@@ -15,7 +15,8 @@ anglebraces: `< ..%(\n/anglebraces/string) `>
brackets: `[ ..%(\n/brackets/string) `]
braces: `{ ..%(\n/braces/string) `}
parens: `( ..%(\n/parens/string) `)
-string: `" ..%(`\.) `" / `' ..%(`\.) `'
+string: `" ..%string-escape `" / `' ..%string-escape `'
+string-escape: `\ (`x 2 Hex / 1-3 `0-7 / `u 1-4 Hex / .)
left-id-edge: ^ / <(\x00-x7f!=id-char) / <((\xc0-xdf \x80-xbf)!=id-char)
/ <((\xe0-xef 2\x80-xbf)!=id-char) / <((\xf0-xf7 3\x80-xbf)!=id-char)
right-id-edge: !id-char
diff --git a/grammars/c++.bp b/grammars/c++.bp
index a48d5a2..1553bb3 100644
--- a/grammars/c++.bp
+++ b/grammars/c++.bp
@@ -7,7 +7,7 @@
# See the accompanying README.md for more info.
comment: "//" .. $ / "/*" ..%\n "*/"
-string: `" ..%(`\.) `"
+string: `" ..%string-escape `"
keyword:
"alignas" / "alignof" / "and" / "and_eq" / "asm" / "atomic_cancel" / "atomic_commit" /
"atomic_noexcept" / "auto" / "bitand" / "bitor" / "bool" / "break" / "case" / "catch" /
diff --git a/grammars/c.bp b/grammars/c.bp
index 2c74c3d..9940ffe 100644
--- a/grammars/c.bp
+++ b/grammars/c.bp
@@ -7,7 +7,8 @@
# See the accompanying README.md for more info.
comment: "//" .. $ / "/*" ..%\n "*/"
-string: `" ..%(`\.) `"
+string: `" ..%string-escape `"
+string-escape: `\ (`x 2 Hex / 1-3 `0-7 / .)
keyword:
"auto" / "break" / "case" / "char" / "const" / "continue" / "default" / "do" /
"double" / "else" / "enum" / "extern" / "float" / "for" / "goto" / "if" /
diff --git a/grammars/go.bp b/grammars/go.bp
index c9f7377..71114cf 100644
--- a/grammars/go.bp
+++ b/grammars/go.bp
@@ -7,7 +7,7 @@
# See the accompanying README.md for more info.
comment: "//" .. $ / "/*" ..%\n "*/"
-string: `" ..%(`\.) `"
+string: `" ..%string-escape `"
keyword:
"break" / "default" / "func" / "interface" / "select" / "case" / "defer" / "go" /
"map" / "struct" / "chan" / "else" / "goto" / "package" / "switch" / "const" /
diff --git a/grammars/javascript.bp b/grammars/javascript.bp
index fdd76a1..76fa586 100644
--- a/grammars/javascript.bp
+++ b/grammars/javascript.bp
@@ -7,7 +7,7 @@
# See the accompanying README.md for more info.
comment: "//" .. $ / "/*" ..%\n "*/"
-string: `" ..%(`\.) `" / `' ..%(`\.) `' / `/ ..%(`\.) `/
+string: `" ..%string-escape `" / `' ..%string-escape `' / `/ ..%string-escape `/
keyword:
"abstract" / "arguments" / "await" / "boolean" / "break" / "byte" / "case" /
"catch" / "char" / "class" / "const" / "continue" / "debugger" / "default" /
diff --git a/grammars/lisp.bp b/grammars/lisp.bp
index d02a458..b7b89ed 100644
--- a/grammars/lisp.bp
+++ b/grammars/lisp.bp
@@ -7,7 +7,7 @@
# See the accompanying README.md for more info.
comment: ";" ..$
-string: `" ..%(`\.) `"
+string: `" ..%string-escape `"
list: parens
function-def: `(__{defun}__id
function: function-def ..%parens `)
diff --git a/grammars/lua.bp b/grammars/lua.bp
index 6967f1e..562b44a 100644
--- a/grammars/lua.bp
+++ b/grammars/lua.bp
@@ -7,7 +7,7 @@
# See the accompanying README.md for more info.
comment: "--" (`[ @eqs=*`= `[ ..%\n (`]eqs`]) / ..$)
-string: `"..%(`\.) `" / `' ..%(`\.) `' / `[ @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" /
diff --git a/grammars/python.bp b/grammars/python.bp
index 37d6a88..cb5d047 100644
--- a/grammars/python.bp
+++ b/grammars/python.bp
@@ -7,7 +7,7 @@
# See the accompanying README.md for more info.
comment: `# ..$
-string: "'''" ..%\n "'''" / '"""' ..%\n '"""' / `" ..%(`\.) `" / `' ..%(`\.) `'
+string: "'''" ..%\n "'''" / '"""' ..%\n '"""' / `" ..%string-escape `" / `' ..%string-escape `'
keyword: "and" / "as" / "assert" / "break" / "class" / "continue" / "def" /
"del" / "elif" / "else" / "except" / "finally" / "for" / "from" /
"global" / "if" / "import" / "in" / "is" / "lambda" / "None" / "nonlocal" /
diff --git a/grammars/rust.bp b/grammars/rust.bp
index 97a1e73..108b41a 100644
--- a/grammars/rust.bp
+++ b/grammars/rust.bp
@@ -7,7 +7,7 @@
# See the accompanying README.md for more info.
comment: "//" .. $ / "/*" ..%(comment / \n) "*/"
-string: `" ..%(`\.) `"
+string: `" ..%string-escape `"
keyword:
"as" / "break" / "const" / "continue" / "crate" / "else" / "enum" / "extern" /
"false" / "fn" / "for" / "if" / "impl" / "in" / "let" / "loop" / "match" /
diff --git a/grammars/shell.bp b/grammars/shell.bp
index ff13d0b..72b83cc 100644
--- a/grammars/shell.bp
+++ b/grammars/shell.bp
@@ -7,8 +7,9 @@
# See the accompanying README.md for more info.
comment: `#..$
-string: `" ..%(`\./subcommand/\n) `" / `' ..%\n `' / "<<" _ @delim=id _$ ..%\n (^delim$)
-subcommand: `` ..%\n `` / "$" parens
+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" /
"else" / "while" / "do" / "done" / "for" / "until" / "case" / "esac" / "break" /