aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-17 20:19:49 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-17 20:19:49 -0800
commit9736ace9a78bb954a8ca4e29696bb3c24489586d (patch)
tree4cd926c7953570d2d365a92a9f43c06c0bf0fae5
parent54b5dfba4df6ddbfdafe7d93e0aa265b67591b2e (diff)
Added C++ grammar and aliases.
l---------grammars/bash.bp1
-rw-r--r--grammars/c++.bp29
-rw-r--r--grammars/c.bp2
l---------grammars/cpp.bp1
4 files changed, 32 insertions, 1 deletions
diff --git a/grammars/bash.bp b/grammars/bash.bp
new file mode 120000
index 0000000..2c3fe18
--- /dev/null
+++ b/grammars/bash.bp
@@ -0,0 +1 @@
+shell.bp \ No newline at end of file
diff --git a/grammars/c++.bp b/grammars/c++.bp
new file mode 100644
index 0000000..843d42d
--- /dev/null
+++ b/grammars/c++.bp
@@ -0,0 +1,29 @@
+# Syntax definition for some C++-specific patterns
+#
+# NOTE: this is *NOT* intended to be a complete definition of the language's
+# syntax! Providing a full language grammar is overkill, because the intended
+# use case is finding/replacing string patterns. This task does not require a
+# full parse tree, and having one makes the task considerably more complicated.
+# See the accompanying README.md for more info.
+
+comment: "//" .. $ / "/*" .. "*/" % \n
+string: `"..`" % (`\.)
+keyword: |(
+ "alignas" / "alignof" / "and" / "and_eq" / "asm" / "atomic_cancel" / "atomic_commit" /
+ "atomic_noexcept" / "auto" / "bitand" / "bitor" / "bool" / "break" / "case" / "catch" /
+ "char" / "char8_t" / "char16_t" / "char32_t" / "class" / "compl" / "concept" / "const" /
+ "consteval" / "constexpr" / "constinit" / "const_cast" / "continue" / "co_await" /
+ "co_return" / "co_yield" / "decltype" / "default" / "delete" / "do" / "double" /
+ "dynamic_cast" / "else" / "enum" / "explicit" / "export" / "extern" / "false" / "float" /
+ "for" / "friend" / "goto" / "if" / "inline" / "int" / "long" / "mutable" / "namespace" /
+ "new" / "noexcept" / "not" / "not_eq" / "nullptr" / "operator" / "or" / "or_eq" /
+ "private" / "protected" / "public" / "reflexpr" / "register" / "reinterpret_cast" /
+ "requires" / "return" / "short" / "signed" / "sizeof" / "static" / "static_assert" /
+ "static_cast" / "struct" / "switch" / "synchronized" / "template" / "this" /
+ "thread_local" / "throw" / "true" / "try" / "typedef" / "typeid" / "typename" / "union" /
+ "unsigned" / "using" / "virtual" / "void" / "volatile" / "wchar_t" / "while" / "xor" / "xor_eq"
+)|
+function-def: ^_ 2+(keyword / id / anglebraces / `*) % __ parens (__`; / >(__`{))
+function: function-def __ braces
+macro: ^"#define " ..$ *(<`\ \n..$)
+import: ^("#include"/"#import")| __ (string / `<..`>)
diff --git a/grammars/c.bp b/grammars/c.bp
index e7c4d22..e5066fa 100644
--- a/grammars/c.bp
+++ b/grammars/c.bp
@@ -18,4 +18,4 @@ keyword: |(
function-def: ^_ 2+(keyword / id / `*) % __ parens (__`; / >(__`{))
function: function-def __ braces
macro: ^"#define " ..$ *(<`\ \n..$)
-import: |"#include"| __ (string / `<..`>)
+import: ^"#include"| __ (string / `<..`>)
diff --git a/grammars/cpp.bp b/grammars/cpp.bp
new file mode 120000
index 0000000..988eed8
--- /dev/null
+++ b/grammars/cpp.bp
@@ -0,0 +1 @@
+c++.bp \ No newline at end of file