(17 lines)
1 # Syntax definitions for some Rust-specific patterns2 #3 # NOTE: this is *NOT* intended to be a complete definition of the language's4 # syntax! Providing a full language grammar is overkill, because the intended5 # use case is finding/replacing string patterns. This task does not require a6 # full parse tree, and having one makes the task considerably more complicated.7 # See the accompanying README.md for more info.9 comment: "//" .. $ / "/*" ..%(comment / \n) "*/"10 string: `" ..%string-escape `"11 keyword: ("as" / "break" / "const" / "continue" / "crate" / "else" / "enum" / "extern" /12 "false" / "fn" / "for" / "if" / "impl" / "in" / "let" / "loop" / "match" /13 "mod" / "move" / "mut" / "pub" / "ref" / "return" / "self" / "Self" / "static" /14 "struct" / "super" / "trait" / "true" / "type" / "unsafe" / "use" / "where" / "while")15 function-def: |"fn"| __ id __ parens __ ["->"__(id / parens)] >(__`{)16 function: function-def __ braces17 import: |"use"| _ *(id / braces) % "::" _ `;