pub enum Statement {
Show 16 variants
ERROR,
LocalFunction(Pointer<LocalFunction>),
LocalAssignment(Pointer<LocalAssignment>),
TypeDefinition(Pointer<TypeDefinition>),
IfStatement(Pointer<IfStatement>),
DoBlock(Pointer<DoBlock>),
GenericFor(Pointer<GenericFor>),
NumericalFor(Pointer<NumericalFor>),
RepeatBlock(Pointer<RepeatBlock>),
WhileLoop(Pointer<WhileLoop>),
SetExpression(Pointer<SetExpression>),
CompoundSetExpression(Pointer<CompoundSetExpression>),
FunctionCall(Pointer<FunctionCall>),
GlobalFunction(Pointer<GlobalFunction>),
TypeFunction(Pointer<TypeFunction>),
EndOfFile(Pointer<EndOfFile>),
}Expand description
All possible statements in a CST, excluding
ending ones.
Variants§
ERROR
This statement had an error and couldn’t parse anything.
LocalFunction(Pointer<LocalFunction>)
A local function.
local function foo(bar: string): Qux
endLocalAssignment(Pointer<LocalAssignment>)
A variable declaration.
local foo = bar
local bar = function()
end
local qux = {}TypeDefinition(Pointer<TypeDefinition>)
A type definition.
type Foo = Bar<string, number>
export type Bar<P, R> = (param: P) -> R
type qux = {}IfStatement(Pointer<IfStatement>)
An if statement.
if a then
print("It's a")
elseif b then
print("It's b")
else
print("It's neither a or b :(")
endDoBlock(Pointer<DoBlock>)
A do block.
do
print("Hello, World!")
end§Note
This struct isn’t used for while or for loops, they have their own tokens, and have do blocks as part of their token.
GenericFor(Pointer<GenericFor>)
A generic for loop.
for i, v in ipairs(t) do
print(`{i}: {v}`)
endNumericalFor(Pointer<NumericalFor>)
A numerical for loop.
for i = 1, 100, 2 do
print(i)
endRepeatBlock(Pointer<RepeatBlock>)
A repeat block.
local i = 0
repeat
print(i)
i += 1
until i == 10WhileLoop(Pointer<WhileLoop>)
A while loop.
local i = 0
while i <= 10 do
print(i)
i += 1
endSetExpression(Pointer<SetExpression>)
A set expression.
a = "test"
b, c = true, false, 1
d, e, f = foo()CompoundSetExpression(Pointer<CompoundSetExpression>)
A compound set expression.
foo += 1
bar //= 2FunctionCall(Pointer<FunctionCall>)
A function call.
local _ = foo(1, 2, 3)GlobalFunction(Pointer<GlobalFunction>)
A global function.
function foo(bar: string): Qux
end
function foo:Qux(bar: string): Qux
endTypeFunction(Pointer<TypeFunction>)
A type function
type function Foo(ty)
return types.unionof(types.string, ty)
end
export type function Bar(ty)
return types.unionof(types.number, ty)
end
type qux = Bar<Foo<boolean>> -- number | string | booleanEndOfFile(Pointer<EndOfFile>)
The EndOfFile token. Read it’s documentation for it’s uses.
Trait Implementations§
Source§impl Ord for Statement
impl Ord for Statement
Source§impl PartialOrd for Statement
impl PartialOrd for Statement
Source§impl Print for Statement
impl Print for Statement
Source§fn print_final_trivia(&self) -> String
fn print_final_trivia(&self) -> String
Prints only the very final trivia. Used for the default implementation of
Print::print, which just joins Print::print_without_final_trivia
and this function.Source§fn print_without_final_trivia(&self) -> String
fn print_without_final_trivia(&self) -> String
Prints the whole token including all surrounding trivia, excluding the
very last trailing trivia.
impl Eq for Statement
impl StructuralPartialEq for Statement
Auto Trait Implementations§
impl Freeze for Statement
impl RefUnwindSafe for Statement
impl !Send for Statement
impl !Sync for Statement
impl Unpin for Statement
impl UnwindSafe for Statement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more