Enum Statement

Source
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
end
§

LocalAssignment(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 :(")
end
§

DoBlock(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}`)
end
§

NumericalFor(Pointer<NumericalFor>)

A numerical for loop.

for i = 1, 100, 2 do
    print(i)
end
§

RepeatBlock(Pointer<RepeatBlock>)

A repeat block.

local i = 0
repeat
    print(i)
    i += 1
until i == 10
§

WhileLoop(Pointer<WhileLoop>)

A while loop.

local i = 0
while i <= 10 do
    print(i)
    i += 1
end
§

SetExpression(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 //= 2
§

FunctionCall(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
end
§

TypeFunction(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 | boolean
§

EndOfFile(Pointer<EndOfFile>)

The EndOfFile token. Read it’s documentation for it’s uses.

Trait Implementations§

Source§

impl Clone for Statement

Source§

fn clone(&self) -> Statement

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Statement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Statement

Source§

fn default() -> Statement

Returns the “default value” for a type. Read more
Source§

impl GetRange for Statement

Source§

fn get_range(&self) -> Result<Range, GetRangeError>

Get the range of the node. Read more
Source§

impl Hash for Statement

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Statement

Source§

fn cmp(&self, other: &Statement) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl Parse for Statement

Source§

fn parse( token: Token, lexer: &mut Lexer, errors: &mut Vec<Error>, ) -> Option<Self>

Try parsing the current item, starting from the passed token.
Source§

impl PartialEq for Statement

Source§

fn eq(&self, other: &Statement) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Statement

Source§

fn partial_cmp(&self, other: &Statement) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Print for Statement

Source§

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

Prints the whole token including all surrounding trivia, excluding the very last trailing trivia.
Source§

fn print(&self) -> String

Prints the whole token including all surrounding trivia.
Source§

impl Eq for Statement

Source§

impl StructuralPartialEq for Statement

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.