[][src]Struct lambda_calc::ast::Ast

pub struct Ast { /* fields omitted */ }

The abstract syntax tree constructed from the lambda expression.

Implementations

impl Ast[src]

pub fn new(expr: Expr) -> Ast[src]

pub fn expr_ref(&self) -> &Expr[src]

Get an un-mutable reference to the underlying expression.

pub fn beta_reduce_print(self, parser: &Parser) -> Option<Ast>[src]

Applies beta reductions until it's no longer possible, printing the result after each round of beta reduction.

Uses normal order reduction strategy (leftmost outermost redex first), otherwise certain reductions would loop infintely:

let mut parser = Parser::new();
let redex = parser
    .parse("(lambda x . a) ((lambda y . y y) (lambda y . y y))", None)
    .unwrap()
    .unwrap();
let non_redex = redex.beta_reduce_print(&parser);
assert_eq!(non_redex, Some(Ast::new(Expr::Var{name: "a".to_string(), is_free: true})));

This function does not attempt to predict infinite loops.

pub fn beta_reduce_quiet(self, parser: &Parser) -> Option<Ast>[src]

Identical to beta_reduce_print() but doesn't print anything.

Trait Implementations

impl Clone for Ast[src]

impl Debug for Ast[src]

impl Display for Ast[src]

If a program will read the output, use the alternate formatter, which does not use ANSI color escapes or non-ASCII unicode characters.

impl Eq for Ast[src]

impl PartialEq<Ast> for Ast[src]

impl StructuralEq for Ast[src]

impl StructuralPartialEq for Ast[src]

Auto Trait Implementations

impl RefUnwindSafe for Ast

impl Send for Ast

impl Sync for Ast

impl Unpin for Ast

impl UnwindSafe for Ast

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.