Struct SyntaxDirectedTranslator

Source
pub struct SyntaxDirectedTranslator<LexemeType: Handled, Context, Satellite> { /* private fields */ }
Expand description

A syntax-directed translation engine based on a LALR parser.

Instances of this type are compiled parsers that’s capable of consuming Lexemes categorized by LexemeType, hold a translation context of type Context, and translate subtrees of the input syntax tree into instances of Satellite.

See parsing and SyntaxDirectedTranslatorBuilder for more details on the parser and its specifications.

Implementations§

Source§

impl<LexemeType, Context, Satellite> SyntaxDirectedTranslator<LexemeType, Context, Satellite>
where LexemeType: AutomaticallyHandled + Debug,

Source

pub fn translate( &self, context: &mut Context, stream: impl Iterator<Item = Lexeme<LexemeType>>, ) -> Option<Satellite>

Parses a sequence of input lexemes.

Operating on the given translation context, the parser consumes the streams’s lexemes, reconstructs their syntax tree, and translates it into an intermediate representation (of type Satellite) according to the user-defined translation scheme specified when the parser was built.

Returns the translated syntax tree, or None if a syntactic error was found.

Auto Trait Implementations§

§

impl<LexemeType, Context, Satellite> Freeze for SyntaxDirectedTranslator<LexemeType, Context, Satellite>
where <LexemeType as Handled>::HandleCoreType: Freeze,

§

impl<LexemeType, Context, Satellite> !RefUnwindSafe for SyntaxDirectedTranslator<LexemeType, Context, Satellite>

§

impl<LexemeType, Context, Satellite> !Send for SyntaxDirectedTranslator<LexemeType, Context, Satellite>

§

impl<LexemeType, Context, Satellite> !Sync for SyntaxDirectedTranslator<LexemeType, Context, Satellite>

§

impl<LexemeType, Context, Satellite> Unpin for SyntaxDirectedTranslator<LexemeType, Context, Satellite>
where <LexemeType as Handled>::HandleCoreType: Unpin,

§

impl<LexemeType, Context, Satellite> !UnwindSafe for SyntaxDirectedTranslator<LexemeType, Context, Satellite>

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.