[−][src]Struct full_moon::ast::Ast
An abstract syntax tree, contains all the nodes used in the code
Implementations
impl<'_> Ast<'_>
[src]
pub fn update_positions(self) -> 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
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 with_nodes(self, nodes: Block<'a>) -> Self
[src]
Returns a new Ast with the given nodes
pub fn with_eof(self, eof: TokenReference<'a>) -> Self
[src]
Returns a new Ast with the given EOF token
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 eof(&self) -> &TokenReference<'a>
[src]
The EOF token at the end of every Ast
Trait Implementations
impl<'a> Clone for Ast<'a>
[src]
impl<'a> Debug for Ast<'a>
[src]
impl<'a> Node<'a> for Ast<'a>
[src]
fn start_position(&self) -> Option<Position>
[src]
fn end_position(&self) -> Option<Position>
[src]
fn similar(&self, other: &Self) -> bool
[src]
fn tokens<'b>(&'b self) -> Tokens<'a, 'b>ⓘ
[src]
fn range(&self) -> Option<(Position, Position)>
[src]
fn surrounding_trivia<'b>(
&'b self
) -> (Vec<Cow<'b, Token<'ast>>>, Vec<Cow<'b, Token<'ast>>>)
[src]
&'b self
) -> (Vec<Cow<'b, Token<'ast>>>, Vec<Cow<'b, Token<'ast>>>)
impl<'a> Owned for Ast<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Ast<'a>
impl<'a> Send for Ast<'a>
impl<'a> Sync for Ast<'a>
impl<'a> Unpin for Ast<'a>
impl<'a> UnwindSafe for Ast<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,