[][src]Enum inc::AST

pub enum AST {
    Nil,
    Number(i64),
    Boolean(bool),
    Char(u8),
    Identifier(String),
    List(Vec<AST>),
    Let {
        bindings: Vec<(String, AST)>,
        body: Vec<AST>,
    },
}

The LISP AST

The canonical type to represent lisp programs. The parser parses the input program to generate an AST. See tests for several examples.

Variants

NilNumber(i64)Boolean(bool)Char(u8)

A unicode char encoded in UTF-8 can take upto 4 bytes and won't fit in a word; so this implementation makes sense only for ASCII.

Identifier(String)List(Vec<AST>)

Since Rust needs to know the size of the AST type upfront, we need an indirection here with Vec<> for recursive types. In this context, Vec is just a convenient way to have a Box<[AST]>

Let

Fields of Let

bindings: Vec<(String, AST)>body: Vec<AST>

Trait Implementations

impl PartialEq<AST> for AST[src]

impl From<i64> for AST[src]

Idiomatic type conversions from the primitive types to AST

https://doc.rust-lang.org/rust-by-example/conversion/from_into.html https://ricardomartins.cc/2016/08/03/convenient_and_idiomatic_conversions_in_rust

impl From<bool> for AST[src]

impl From<char> for AST[src]

impl<'_> From<&'_ str> for AST[src]

impl Debug for AST[src]

impl FromStr for AST[src]

Parse the input from user into the form the top level of the compiler understands.

type Err = Error

The associated error which can be returned from parsing.

Auto Trait Implementations

impl Send for AST

impl Sync for AST

Blanket Implementations

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

impl<T> From<T> for T[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.

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

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

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