Struct passerine::compiler::rule::Rule[][src]

pub struct Rule {
    pub arg_pat: Spanned<ArgPat>,
    pub tree: Spanned<AST>,
}

A rule has an Argument Pattern and an AST. When a form matches the ArgPat, 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<ArgPat>tree: Spanned<AST>

Implementations

impl Rule[src]

pub fn new(arg_pat: Spanned<ArgPat>, tree: Spanned<AST>) -> Result<Rule, Syntax>[src]

Builds a new rule, making sure the rule's signature is valid.

pub fn keywords(arg_pat: &Spanned<ArgPat>) -> Vec<String>[src]

Returns all keywords, as strings, used by the macro, in order of usage. Does not filter for duplicates.

pub fn merge_safe(
    base: &mut HashMap<String, Spanned<AST>>,
    new: HashMap<String, Spanned<AST>>,
    def: Span
) -> Result<(), Syntax>
[src]

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.

pub fn bind(
    arg_pat: &Spanned<ArgPat>,
    reversed_form: &mut Vec<Spanned<AST>>
) -> Option<Result<HashMap<String, Spanned<AST>>, Syntax>>
[src]

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.

pub fn remove_tag(base: &str) -> String[src]

Turns a tagged random identifier, like <base>#XXXXXXXX back into <base>. If the identifier is not tagged, this function just returns <base>.

pub fn unique_tag(
    base: String,
    bindings: &HashMap<String, Spanned<AST>>
) -> String
[src]

Turns a base identifier into a random identifier of the format <base>#XXXXXXXX, Gauranteed not to exist in bindings.

pub fn resolve_symbol(
    name: String,
    span: Span,
    bindings: &mut HashMap<String, Spanned<AST>>
) -> Spanned<AST>
[src]

Resolves a symbol. If the symbol has been bound, i.e. is defined in the Argument Pattern, 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>
[src]

Expands the bindings in a pattern.

pub fn expand_arg_pat(
    arg_pat: Spanned<ArgPat>,
    bindings: &mut HashMap<String, Spanned<AST>>
) -> Result<Spanned<ArgPat>, Syntax>
[src]

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

pub fn expand(
    tree: Spanned<AST>,
    bindings: &mut HashMap<String, Spanned<AST>>
) -> Result<Spanned<AST>, Syntax>
[src]

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

Trait Implementations

impl Clone for Rule[src]

impl Debug for Rule[src]

Auto Trait Implementations

impl !RefUnwindSafe for Rule[src]

impl !Send for Rule[src]

impl !Sync for Rule[src]

impl Unpin for Rule[src]

impl !UnwindSafe for Rule[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.