[][src]Struct full_moon::ast::Ast

pub struct Ast<'a> { /* fields omitted */ }

An abstract syntax tree, contains all the nodes used in the code

Methods

impl<'a> Ast<'a>[src]

pub fn from_tokens(tokens: Vec<Token<'a>>) -> Result<Ast<'a>, AstError<'a>>[src]

Create an Ast from the passed tokens. You probably want parse

Errors

If the tokens passed are impossible to get through normal tokenization, an error of Empty (if the vector is empty) or NoEof (if there is no eof token) will be returned.

More likely, if the tokens pass are invalid Lua 5.1 code, an UnexpectedToken error will be returned.

pub fn nodes(&self) -> &Block<'a>[src]

The entire code of the function

assert_eq!(full_moon::parse("local x = 1; local y = 2")?.nodes().iter_stmts().count(), 2);

pub fn nodes_mut(&mut self) -> &mut Block<'a>[src]

The entire code of the function, but mutable

pub fn iter_tokens(&self) -> impl Iterator<Item = &Token<'a>>[src]

An iterator over the tokens used to create the Ast

pub fn update_positions(&mut self)[src]

Will update the positions of all the tokens in the tree Necessary if you are both mutating the tree and need the positions of the tokens

Trait Implementations

impl<'_> Owned for Ast<'_>[src]

type Owned = Ast<'static>

What an owned version of the object looks like. Usually contains a 'static lifetime.

impl<'a> Clone for Ast<'a>[src]

impl<'a> Debug for Ast<'a>[src]

Auto Trait Implementations

impl<'a> Send for Ast<'a>

impl<'a> Unpin for Ast<'a>

impl<'a> Sync for Ast<'a>

impl<'a> !UnwindSafe for Ast<'a>

impl<'a> !RefUnwindSafe for Ast<'a>

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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]