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    comment,
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}