Expand description
This file contains code for parsing SSR rules, which look something like foo($a) ==>> bar($b).
We first split everything before and after the separator ==>>. Next, both the search pattern
and the replacement template get tokenized by the Rust tokenizer. Tokens are then searched for
placeholders, which start with $. For replacement templates, this is the final form. For
search patterns, we go further and parse the pattern as each kind of thing that we can match.
e.g. expressions, type references etc.
Structsยง
- Parsed
Rule ๐ - Placeholder ๐
- RawPattern ๐
- Rule
Builder ๐ - Token ๐
- Var ๐
- Represents a
$varin an SSR query.
Enumsยง
- Constraint ๐
- Node
Kind ๐ - Pattern
Element ๐
Functionsยง
- contains_
path ๐ - Returns whether there are any paths in
node. - expect_
token ๐ - parse_
constraint ๐ - parse_
pattern ๐ - Returns
pattern_str, parsed as a search or replace pattern. Ifremove_whitespaceis true, then any whitespace tokens will be removed, which we do for the search pattern, but not for the replace pattern. - parse_
placeholder ๐ - tokenize ๐
- validate_
rule ๐ - Checks for errors in a rule. e.g. the replace pattern referencing placeholders that the search pattern didnโt define.