diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-01-17 20:05:19 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-01-17 20:05:19 -0800 |
| commit | 008db802298d688067ed9615079be28978e60e28 (patch) | |
| tree | eb1a4e080aad6356852b4712b5bdc1901e817697 /grammars/rust.bp | |
| parent | fdc91544b7c7a57243e5504c29dab68e45cc79cc (diff) | |
Adding and improving grammars.
Diffstat (limited to 'grammars/rust.bp')
| -rw-r--r-- | grammars/rust.bp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/grammars/rust.bp b/grammars/rust.bp new file mode 100644 index 0000000..003427a --- /dev/null +++ b/grammars/rust.bp @@ -0,0 +1,19 @@ +# Syntax definitions for some Rust-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: "//" .. $ / "/*" .. "*/" % (comment / \n) +string: `"..`" % (`\.) +keyword: |( + "as" / "break" / "const" / "continue" / "crate" / "else" / "enum" / "extern" / + "false" / "fn" / "for" / "if" / "impl" / "in" / "let" / "loop" / "match" / + "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: function-def __ braces +import: |"use"| _ *(id / braces) % "::" _ `; |
