1use super::{Expr, Span, Type};
2use alloc::{string::String, vec::Vec};
3#[derive(Debug, Clone, PartialEq)]
4pub struct Stmt {
5 pub kind: StmtKind,
6 pub span: Span,
7}
8
9impl Stmt {
10 pub fn new(kind: StmtKind, span: Span) -> Self {
11 Self { kind, span }
12 }
13}
14
15#[derive(Debug, Clone, PartialEq)]
16pub struct LocalBinding {
17 pub name: String,
18 pub type_annotation: Option<Type>,
19 pub span: Span,
20}
21
22#[derive(Debug, Clone, PartialEq)]
23pub enum StmtKind {
24 Local {
25 bindings: Vec<LocalBinding>,
26 mutable: bool,
27 initializer: Option<Vec<Expr>>,
28 },
29 Assign {
30 targets: Vec<Expr>,
31 values: Vec<Expr>,
32 },
33 CompoundAssign {
34 target: Expr,
35 op: super::expr::BinaryOp,
36 value: Expr,
37 },
38 Expr(Expr),
39 If {
40 condition: Expr,
41 then_block: Vec<Stmt>,
42 elseif_branches: Vec<(Expr, Vec<Stmt>)>,
43 else_block: Option<Vec<Stmt>>,
44 },
45 While {
46 condition: Expr,
47 body: Vec<Stmt>,
48 },
49 ForNumeric {
50 variable: String,
51 start: Expr,
52 end: Expr,
53 step: Option<Expr>,
54 body: Vec<Stmt>,
55 },
56 ForIn {
57 variables: Vec<String>,
58 iterator: Expr,
59 body: Vec<Stmt>,
60 },
61 Return(Vec<Expr>),
62 Break,
63 Continue,
64 Block(Vec<Stmt>),
65}