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

pub struct Transformer { /* fields omitted */ }
Expand description

Applies compile-time transformations to the AST.

Implementations

Creates a new transformer with no macro transformation rules.

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

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.

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

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.

Desugar a tuple. Nothing fancy here.

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.

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

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

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

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

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.

Trait Implementations

Returns the “default value” for a type. 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 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.