Struct Hoister

Source
pub struct Hoister { /* private fields */ }
Expand description

Keeps track of:

  1. Local and nonlocal variables in each scope.
  2. All variables declared.
  3. Variables that have been used but not declared.

Implementations§

Source§

impl Hoister

Source

pub fn new() -> Hoister

Creates a new hoisted in a root scope. Note that the hoister will always have a root scope.

Source§

impl Hoister

Source

pub fn walk(&mut self, cst: Spanned<CST>) -> Result<Spanned<SST>, Syntax>

Walks a CST to produce an SST. This is fairly standard - hoisting happens in self.assign, self.lambda, and self.symbol.

Source

pub fn walk_pattern( &mut self, pattern: Spanned<CSTPattern>, declare: bool, ) -> Spanned<SSTPattern>

Walks a pattern. If declare is true, we shadow variables in existing scopes and creates a new variable in the local scope.

Source

pub fn symbol(&mut self, name: &str) -> SST

Replaces a symbol name with a unique identifier for that symbol

Source

pub fn block(&mut self, block: Vec<Spanned<CST>>) -> Result<SST, Syntax>

Walks a block, nothing fancy here.

Source

pub fn tuple(&mut self, tuple: Vec<Spanned<CST>>) -> Result<SST, Syntax>

Walks a tuple, nothing fancy here.

Source

pub fn assign( &mut self, pattern: Spanned<CSTPattern>, expression: Spanned<CST>, ) -> Result<SST, Syntax>

Walks an assignment. Delegates to walk_pattern for capturing. Assignments can capture existing variables

Source

pub fn lambda( &mut self, pattern: Spanned<CSTPattern>, expression: Spanned<CST>, ) -> Result<SST, Syntax>

Walks a function definition. Like assign, delegates to walk_pattern for capturing. But any paramaters will shadow those in outer scopes.

Source

pub fn call( &mut self, fun: Spanned<CST>, arg: Spanned<CST>, ) -> Result<SST, Syntax>

Walks a function call.

Trait Implementations§

Source§

impl Default for Hoister

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.