ParseCtx

Struct ParseCtx 

Source
pub struct ParseCtx {
    pub errs: Vec<Spanned<Error>>,
    /* private fields */
}
Expand description

Compile parsed to executable filters.

This allows to go from a parsed filter to a filter executable by this crate.

Fields§

§errs: Vec<Spanned<Error>>

errors occurred during transformation

Implementations§

Source§

impl ParseCtx

Source

pub fn new(vars: Vec<String>) -> Self

Initialise new context with list of global variables.

When running a filter produced by this context, values corresponding to the variables have to be supplied in the execution context.

Source

pub fn insert_native(&mut self, name: String, arity: usize, f: Native)

Add a native filter with given name and arity.

Source

pub fn insert_natives<I>(&mut self, natives: I)
where I: IntoIterator<Item = (String, usize, Native)>,

Add native filters with given names and arities.

Source

pub fn insert_defs(&mut self, defs: impl IntoIterator<Item = Def>)

Import parsed definitions, such as obtained from the standard library.

Errors that might occur include undefined variables, for example.

Source

pub fn root_def(&mut self, def: Def)

👎Deprecated since 1.1.0: use insert_defs instead

Insert a root definition.

Source

pub fn root_filter(&mut self, filter: Spanned<Filter>)

👎Deprecated since 1.1.0: this call has no effect

Insert a root filter.

Source

pub fn compile(&mut self, main: Main) -> Filter

Given a main filter (consisting of definitions and a body), return a finished filter.

Source

pub fn yields(&mut self, x: Val, f: Main, ys: impl Iterator<Item = ValR>)

Compile and run a filter on given input, panic if it does not compile or yield the given output.

This is for testing purposes.

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.