Expand description
Concrete Syntax Parser
Parses Rust-like pattern syntax with metavariables into CodePattern.
§Syntax
| Syntax | Meaning | Example |
|---|---|---|
$VAR | Capture single node | $receiver.unwrap() |
$_ | Match but don’t capture | foo($_, $second) |
$...VAR | Capture sequence (ellipsis) | fn $name($...args) |
§Important
Patterns must be valid Rust syntax after metavariable substitution.
For example, match $x { $_ } is invalid because match arms require => body.
§Examples
ⓘ
use ryo_pattern::concrete::parse_pattern;
// Parse a method call pattern
let pattern = parse_pattern("$receiver.unwrap()").unwrap();
// Parse a macro call pattern
let pattern = parse_pattern("vec![$x]").unwrap();
// Parse a match expression (requires complete arm syntax)
let pattern = parse_pattern("match $x { _ => $body }").unwrap();Structs§
- Concrete
Parser - Parser for concrete syntax patterns
Enums§
- Parse
Error - Errors that can occur during pattern parsing
Functions§
- parse_
pattern - Parse a concrete syntax pattern string into a CodePattern
Type Aliases§
- Parse
Result - Result type for pattern parsing