Struct passerine::compiler::desugar::Transformer[][src]

pub struct Transformer { /* fields omitted */ }

Applies compile-time transformations to the AST.

Implementations

impl Transformer[src]

pub fn new() -> Transformer[src]

Creates a new transformer with no macro transformation rules.

pub fn walk(&mut self, ast: Spanned<AST>) -> Result<Spanned<CST>, Syntax>[src]

Desugars an AST into a CST, By walking over it in a fairly straight-forward manner.

pub fn symbol(&mut self, ast: Spanned<AST>) -> Result<CST, Syntax>[src]

Converts a symbol. Note that symbols can be one-item macros; Function calls are always parsed with at least two items, So we need to wrap this symbol in a vec and interpret it as a form.

pub fn call(&mut self, f: Vec<Spanned<AST>>) -> Result<CST, Syntax>[src]

Recursively build up a call from a flat form. Basically turns (a b c d) into (((a b) c) d).

pub fn form(&mut self, form: Vec<Spanned<AST>>) -> Result<CST, Syntax>[src]

Desugars a form. This is where most of the macro logic resides. Applying a macro really happens in four broad strokes:

  1. We match the form against all macros currently in scope.
  2. If there was one match, we're done! we apply the macro and keep on going.
  3. If there were no matches, we ensure that it couldn't've been a macro, then parse it as a function call.
  4. If there was more than one match, we point out the ambiguity.

pub fn tuple(&mut self, tuple: Vec<Spanned<AST>>) -> Result<CST, Syntax>[src]

Desugar a tuple. Nothing fancy here.

pub fn composition(
    &mut self,
    argument: Spanned<AST>,
    function: Spanned<AST>
) -> Result<CST, Syntax>
[src]

Desugar a function application. A composition takes the form c . b . a and is left-associative (c . b) . a. When desugared, the above is equivalent to the call a b c.

pub fn ffi(
    &mut self,
    name: String,
    expression: Spanned<AST>
) -> Result<CST, Syntax>
[src]

Desugar a FFI call. We walk the expression that may be passed to the FFI.

pub fn block(&mut self, block: Vec<Spanned<AST>>) -> Result<CST, Syntax>[src]

Desugars a block, i.e. a series of expressions that takes on the value of the last one.

pub fn assign(
    &mut self,
    p: Spanned<ASTPattern>,
    e: Spanned<AST>
) -> Result<CST, Syntax>
[src]

Desugars an assigment. Note that this converts the assignment's ASTPattern into a CSTPattern

pub fn lambda(
    &mut self,
    p: Spanned<ASTPattern>,
    e: Spanned<AST>
) -> Result<CST, Syntax>
[src]

Desugars a lambda This converts both patterns and expressions; On top of this, it desugars a b c -> d into a -> b -> c -> d.

pub fn rule(
    &mut self,
    arg_pat: Spanned<ArgPat>,
    tree: Spanned<AST>
) -> Result<CST, Syntax>
[src]

Desugars a macro definition. Right now, this is a bit awkward; Ideally, a preprocessing step should be taken That determines which variables are declared where, Which macros are declared when, And removes all such valueless declarations from the AST.

Auto Trait Implementations

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