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.

Expands the bindings in a pattern.

~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.

Takes a macro’s tree and a set of bindings and produces a new hygenic tree.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.