Skip to main content

EvalSite

Struct EvalSite 

Source
pub struct EvalSite<'a> { /* private fields */ }
Expand description

The site an evaluator is called from: the rule the reduction belongs to and the live parse context, and neither when evaluation is called on a finished tree.

The rule is a snapshot rather than the live rule, because the canonical port hands the evaluator the PARENT of the rule that is closing, which this engine exposes as a snapshot. Its state, its u flags and its node cell are all reachable through it.

Implementations§

Source§

impl<'a> EvalSite<'a>

Source

pub fn detached() -> Self

A site with no live parse behind it.

Source

pub fn new(rule: Option<Rc<RuleSnapshot>>, context: &'a mut Context) -> Self

A site inside a parse.

Source

pub fn rule(&self) -> Option<&RuleSnapshot>

The rule the reduction belongs to, when there is one.

Source

pub fn token(&self) -> Option<&Token>

The token this OCCURRENCE of the operator was matched from.

The Op an evaluator receives is the shared description, one per entry in the operator table, so it cannot say which occurrence is being reduced. The canonical makeOp attaches the token to its copy of the description for exactly that reason; this port keeps the token beside the node instead, and hands it over here. The position is the engine’s Site triple: token.site.pos, .ri (row) and .ci (column).

It is None when the node was built without one, which is what prattify called directly produces.

Source

pub fn context(&mut self) -> Option<&mut Context>

The live parse context, when there is one.

Source

pub fn flag(&self, name: &str) -> bool

Whether the rule carries a u flag set to true. The paren_preval flag is what tells an evaluator that a paren operator’s first term is the preceding value.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for EvalSite<'a>

§

impl<'a> !Send for EvalSite<'a>

§

impl<'a> !Sync for EvalSite<'a>

§

impl<'a> !UnwindSafe for EvalSite<'a>

§

impl<'a> Freeze for EvalSite<'a>

§

impl<'a> Unpin for EvalSite<'a>

§

impl<'a> UnsafeUnpin for EvalSite<'a>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.