pub struct Ast { /* private fields */ }Expand description
The abstract syntax tree constructed from the lambda expression.
Implementations§
Source§impl Ast
impl Ast
pub fn new(expr: Expr) -> Ast
Sourcepub fn beta_reduce_print(self, parser: &Parser) -> Option<Ast>
pub fn beta_reduce_print(self, parser: &Parser) -> Option<Ast>
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.
Sourcepub fn beta_reduce_quiet(self, parser: &Parser) -> Option<Ast>
pub fn beta_reduce_quiet(self, parser: &Parser) -> Option<Ast>
Identical to beta_reduce_print() but doesn’t print anything.
Trait Implementations§
Source§impl Display for Ast
If a program will read the output, use the alternate formatter,
which does not use ANSI color escapes or non-ASCII unicode characters.
impl Display for Ast
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
impl StructuralPartialEq for Ast
Auto Trait Implementations§
impl Freeze for Ast
impl RefUnwindSafe for Ast
impl Send for Ast
impl Sync for Ast
impl Unpin for Ast
impl UnwindSafe for Ast
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more