pub struct Compiler { /* private fields */ }Expand description
A Muse compiler instance.
Implementations§
source§impl Compiler
impl Compiler
sourcepub fn push<'a>(&mut self, source: impl Into<SourceCode<'a>>)
pub fn push<'a>(&mut self, source: impl Into<SourceCode<'a>>)
Pushes source into the list of sources to build.
sourcepub fn with<'a>(self, source: impl Into<SourceCode<'a>>) -> Self
pub fn with<'a>(self, source: impl Into<SourceCode<'a>>) -> Self
Adds source to this compiler, and returns self.
sourcepub fn push_macro<M>(&mut self, name: impl Into<Symbol>, func: M)where
M: MacroFn + 'static,
pub fn push_macro<M>(&mut self, name: impl Into<Symbol>, func: M)where
M: MacroFn + 'static,
Adds a macro to this compiler instance.
Macros are functions that accept a VecDeque<Ranged<Token>> and return
a VecDeque<Ranged<Token>>.
sourcepub fn with_macro<M>(self, name: impl Into<Symbol>, func: M) -> Selfwhere
M: MacroFn + 'static,
pub fn with_macro<M>(self, name: impl Into<Symbol>, func: M) -> Selfwhere
M: MacroFn + 'static,
Adds a macro to this compiler instance and returns self.
Macros are functions that accept a VecDeque<Ranged<Token>> and return
a VecDeque<Ranged<Token>>.
sourcepub fn push_infix_macro<M>(&mut self, name: impl Into<Symbol>, func: M)where
M: InfixMacroFn + 'static,
pub fn push_infix_macro<M>(&mut self, name: impl Into<Symbol>, func: M)where
M: InfixMacroFn + 'static,
Adds an infix macro to this compiler instance.
Infix macros are functions that accept a Ranged<Expression> and a
VecDeque<Ranged<Token>> and returns a VecDeque<Ranged<Token>>.
sourcepub fn with_infix_macro<M>(self, name: impl Into<Symbol>, func: M) -> Selfwhere
M: InfixMacroFn + 'static,
pub fn with_infix_macro<M>(self, name: impl Into<Symbol>, func: M) -> Selfwhere
M: InfixMacroFn + 'static,
Adds an infix macro to this compiler instance, and returns self.
Infix macros are functions that accept a Ranged<Expression> and a
VecDeque<Ranged<Token>> and returns a VecDeque<Ranged<Token>>.
sourcepub fn compile<'a>(
source: impl Into<SourceCode<'a>>,
guard: &CollectionGuard<'_>,
) -> Result<Code, Vec<Ranged<Error>>>
pub fn compile<'a>( source: impl Into<SourceCode<'a>>, guard: &CollectionGuard<'_>, ) -> Result<Code, Vec<Ranged<Error>>>
Compile’s source.
sourcepub fn build(
&mut self,
guard: &CollectionGuard<'_>,
) -> Result<Code, Vec<Ranged<Error>>>
pub fn build( &mut self, guard: &CollectionGuard<'_>, ) -> Result<Code, Vec<Ranged<Error>>>
Builds all of the sources added to this compiler into a single code block.
sourcepub fn expand_macros(&mut self, expr: &mut Ranged<Expression>)
pub fn expand_macros(&mut self, expr: &mut Ranged<Expression>)
Perform macro expansion on expr.
After this function executions expr and all subexpressions will not
contain any Expression::Macros.