aboutsummaryrefslogtreecommitdiff
path: root/grammars/rust.bp
blob: a96062d4d98806aa187bbcfee3dd1d6495f35e11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 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: `" ..%string-escape `"
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: \b"fn"\b __ id __ parens __ ["->"__(id / parens)] >(__`{)
function: function-def __ braces
import: \b"use"\b _ *(id / braces) % "::" _ `;