Struct Translator

struct Translator { ... }

A translator maps abstract syntax to a high level intermediate representation.

A translator may be benefit from reuse. That is, a translator can translate many abstract syntax trees.

A Translator can be configured in more detail via a TranslatorBuilder.

Implementations

impl Translator

fn new() -> Translator

Create a new translator using the default configuration.

fn translate(self: &mut Self, pattern: &str, ast: &Ast) -> Result<Hir, Error>

Translate the given abstract syntax tree (AST) into a high level intermediate representation (HIR).

If there was a problem doing the translation, then an HIR-specific error is returned.

The original pattern string used to produce the Ast must also be provided. The translator does not use the pattern string during any correct translation, but is used for error reporting.

impl Clone for Translator

fn clone(self: &Self) -> Translator

impl Debug for Translator

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Freeze for Translator

impl RefUnwindSafe for Translator

impl Send for Translator

impl Sync for Translator

impl Unpin for Translator

impl UnsafeUnpin for Translator

impl UnwindSafe for Translator

impl<T> Any for Translator

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Translator

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Translator

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

impl<T> CloneToUninit for Translator

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Translator

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Translator

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Translator

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for Translator

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

impl<T, U> TryInto for Translator

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