Struct passerine::compiler::rule::Rule [−][src]
pub struct Rule {
pub arg_pat: Spanned<ArgPattern>,
pub tree: Spanned<AST>,
}
Expand description
A rule has an Argument Pattern and an AST
.
When a form matches the ArgPattern
,
a set of bindings are produced,
which are then spliced into the Rule’s AST
to make a new AST
.
This is done in a hygenic manner.
Fields
arg_pat: Spanned<ArgPattern>
tree: Spanned<AST>
Implementations
Builds a new rule, making sure the rule’s signature is valid.
Returns all keywords, as strings, used by the macro, in order of usage. Does not filter for duplicates.
Merges two maps of bindings. If there is a collision, i.e. a name bound in both bindings, An error highlighting the duplicate binding is returned.
Traverses a form, creating bindings for subsequent transformation.
Returns None
if the form does not match the argument pattern.
Some(Ok(_))
if it matches successfully,
and Some(Err(_))
if it matches but something is incorrect.
You must check that the passed &mut reversed_form
is empty
to gaurantee the match occured in full
Note that this function takes the form unwrapped and in reverse -
This is to make processing the bindings more efficient,
As this function works with the head of the form.
Turns a tagged random identifier, like
<base>#XXXXXXXX
back into <base>
.
If the identifier is not tagged, this function just
returns <base>
.
Turns a base identifier into a random identifier
of the format <base>#XXXXXXXX
,
Gauranteed not to exist in bindings.
Resolves a symbol. If the symbol has been bound, i.e. is defined in the Argument CSTPattern, we simply splice that in. If not, we hygenically replace it with a unique variable.
pub fn expand_pattern(
pattern: Spanned<ASTPattern>,
bindings: &mut HashMap<String, Spanned<AST>>
) -> Result<Spanned<ASTPattern>, Syntax>
pub fn expand_pattern(
pattern: Spanned<ASTPattern>,
bindings: &mut HashMap<String, Spanned<AST>>
) -> Result<Spanned<ASTPattern>, Syntax>
Expands the bindings in a pattern.
pub fn expand_arg_pat(
arg_pat: Spanned<ArgPattern>,
bindings: &mut HashMap<String, Spanned<AST>>
) -> Result<Spanned<ArgPattern>, Syntax>
pub fn expand_arg_pat(
arg_pat: Spanned<ArgPattern>,
bindings: &mut HashMap<String, Spanned<AST>>
) -> Result<Spanned<ArgPattern>, Syntax>
~Macros inside of macros is a bit too meta for me to think about atm.~ No longer! A macro inside a macro is a macro completely local to that macro. The argument patterns inside a macro can be extended.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Rule
impl !UnwindSafe for Rule
Blanket Implementations
Mutably borrows from an owned value. Read more