Skip to main content

Crate treesitter_types_lua

Crate treesitter_types_lua 

Source
Expand description

Strongly-typed AST types for Lua, auto-generated from tree-sitter-lua’s node-types.json.

This crate is generated by treesitter-types and is automatically kept up to date when a new version of the grammar crate is released.

See the Tree-sitter project for more information about the underlying parser framework.

§Example

use treesitter_types_lua::*;

// A minimal Lua hello-world program.
let src = b"\
function greet(name)
    print(\"Hello, \" .. name .. \"!\")
end

greet(\"World\")
";

// Parse the source with tree-sitter and convert into typed AST.
let mut parser = tree_sitter::Parser::new();
parser.set_language(&tree_sitter_lua::LANGUAGE.into()).unwrap();
let tree = parser.parse(src, None).unwrap();
let chunk = Chunk::from_node(tree.root_node(), src).unwrap();

// The chunk has two top-level children:
// a function statement and a function call statement.
assert_eq!(chunk.children.len(), 2);
assert_eq!(chunk.span.start.row, 0);
assert!(chunk.span.end.row >= 4);

Re-exports§

pub use tree_sitter_lua;
pub use treesitter_types::tree_sitter;

Structs§

Arguments
AssignmentStatement
Attribute
BinaryExpression
Block
BracketIndexExpression
BreakStatement
Chunk
Comment
CommentContent
DoStatement
DotIndexExpression
ElseStatement
ElseifStatement
EmptyStatement
EscapeSequence
ExpressionList
False
Field
ForGenericClause
ForNumericClause
ForStatement
FunctionCall
FunctionDeclaration
FunctionDefinition
GotoStatement
HashBangLine
Identifier
IfStatement
ImplicitVariableDeclaration
LabelStatement
MethodIndexExpression
Nil
Number
Parameters
ParenthesizedExpression
RepeatStatement
ReturnStatement
Span
String
StringContent
TableConstructor
True
UnaryExpression
VarargExpression
VariableDeclaration
VariableList
WhileStatement

Enums§

AnyNode
AssignmentStatementChildren
AssignmentStatementOperator
BinaryExpressionOperator
BlockChildren
BracketIndexExpressionTable
ChunkChildren
CommentEnd
CommentStart
Declaration
DotIndexExpressionTable
Expression
FieldName
FieldOperator
ForGenericClauseChildren
ForNumericClauseOperator
ForStatementClause
FunctionCallName
FunctionDeclarationName
IfStatementAlternative
MethodIndexExpressionTable
ParseError
Statement
StringEnd
StringStart
UnaryExpressionOperator
Variable
VariableDeclarationChildren

Traits§

FromNode
Every generated struct and enum implements this.
LeafNode
Implemented by every generated leaf type (identifiers, literals, etc.)
Spanned
Implemented by every generated type that has a source location.