yog_script_analyze/ast/
stmt.rs1use super::{Expr, Name, Type};
4use crate::source::token::Span;
5
6#[derive(Debug, Clone, PartialEq)]
7pub struct Block {
8 pub stmts: Vec<Stmt>,
9 pub span: Span,
10}
11
12#[derive(Debug, Clone, PartialEq)]
15pub enum Binding {
16 One(Name),
17 Tuple(Vec<Name>),
18}
19
20#[derive(Debug, Clone, PartialEq)]
21pub enum Stmt {
22 Local {
25 ty: Option<Type>,
26 binding: Binding,
27 value: Option<Expr>,
28 mutable: bool,
30 },
31 Assign {
33 place: Expr,
34 op: Option<super::BinOp>,
35 value: Expr,
36 },
37 If {
38 cond: Expr,
39 then: Box<Stmt>,
40 otherwise: Option<Box<Stmt>>,
41 },
42 Foreach {
43 ty: Option<Type>,
44 binding: Binding,
45 iter: Expr,
46 body: Box<Stmt>,
47 },
48 For {
49 init: Option<Box<Stmt>>,
50 cond: Option<Expr>,
51 step: Option<Box<Stmt>>,
52 body: Box<Stmt>,
53 },
54 While {
55 cond: Expr,
56 body: Box<Stmt>,
57 },
58 DoWhile {
59 body: Box<Stmt>,
60 cond: Expr,
61 },
62 Block(Block),
63 Break(Span),
64 Continue(Span),
65 Return(Option<Expr>, Span),
66 Skip(Option<Expr>, Span),
68 Expr(Expr),
69 Value(Expr),
71}