Ast
An abstract syntax tree that contains all the nodes used in the parsed Lua code.Methods
nodes
Returns a reference to the entire code block of the AST.A reference to the block containing all statements in the AST
nodes_mut
Returns a mutable reference to the entire code block of the AST.A mutable reference to the block containing all statements
eof
Returns the EOF (end-of-file) token at the end of the AST.The EOF token at the end of every Ast
with_nodes
Returns a new Ast with the given nodes.The new block to use in the AST
A new Ast instance with the updated nodes
with_eof
Returns a new Ast with the given EOF token.The new EOF token to use
A new Ast instance with the updated EOF token
Display Trait
TheAst implements Display, allowing you to convert it back to Lua code:
AstResult
A producedAst along with any errors found during parsing. This Ast may not be exactly the same as the input code, as reconstruction may have occurred.
Methods
ast
Returns a reference to theAst that was parsed.
A reference to the parsed AST (may contain phantom tokens if there were errors)
into_ast
Consumes theAstResult and returns the parsed Ast.
The owned Ast instance
errors
Returns all errors that occurred during parsing.A slice of all parsing errors
into_result
Consumes this AstResult, converting it to aResult.
Returns
Ok(Ast) if there were no errors, otherwise Err(Vec<Error>)Example Usage
See Also
- parse - Parse Lua code into an AST
- parse_fallible - Parse with error recovery
- Block - The block structure containing statements