luau_parser/types/block/
mod.rs

1//! Module holding all possible blocks in Luau (excluding functions).
2
3use luau_lexer::prelude::Token;
4
5use crate::types::Pointer;
6
7reexport!(
8    do_block,
9    end_of_file,
10    generic_for,
11    if_statement,
12    local_assignment,
13    numerical_for,
14    function,
15    repeat_block,
16    set_expressions,
17    statement,
18    type_definition,
19    while_loop,
20);
21
22/// A block of code that represents a single scope (and nested ones).
23#[derive(Clone, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
24#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
25pub struct Block {
26    /// The tokens in the of this [`block`](Block) **only**. Parent
27    /// [`blocks`](Block)' tokens won't be included. The optional [`Token`]
28    /// is the optional semicolon after the statement.
29    pub statements: Vec<(Pointer<Statement>, Option<Token>)>,
30
31    /// The [`last statement`](TerminationStatement) (aka termination statement)
32    /// of this scope. The optional [`Token`] is the optional semicolon after the
33    /// statement.
34    pub last_statement: Option<(Pointer<TerminationStatement>, Option<Token>)>,
35}