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    generic_for,
10    if_statement,
11    local_assignment,
12    numerical_for,
13    function,
14    repeat_block,
15    set_expressions,
16    statement,
17    type_definition,
18    while_loop,
19);
20
21/// A block of code that represents a single scope (and nested ones).
22#[derive(Clone, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
23#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
24pub struct Block {
25    /// The tokens in the of this [`block`](Block) **only**. Parent
26    /// [`blocks`](Block)' tokens won't be included. The optional [`Token`]
27    /// is the optional semicolon after the statement.
28    pub statements: Vec<(Pointer<Statement>, Option<Token>)>,
29
30    /// The [`last statement`](TerminationStatement) (aka termination statement)
31    /// of this scope. The optional [`Token`] is the optional semicolon after the
32    /// statement.
33    pub last_statement: Option<(Pointer<TerminationStatement>, Option<Token>)>,
34}