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 {
24 ty: Option<Type>,
25 binding: Binding,
26 value: Option<Expr>,
27 },
28 Assign {
30 place: Expr,
31 op: Option<super::BinOp>,
32 value: Expr,
33 },
34 If {
35 cond: Expr,
36 then: Box<Stmt>,
37 otherwise: Option<Box<Stmt>>,
38 },
39 Foreach {
40 ty: Option<Type>,
41 binding: Binding,
42 iter: Expr,
43 body: Box<Stmt>,
44 },
45 For {
46 init: Option<Box<Stmt>>,
47 cond: Option<Expr>,
48 step: Option<Box<Stmt>>,
49 body: Box<Stmt>,
50 },
51 While {
52 cond: Expr,
53 body: Box<Stmt>,
54 },
55 DoWhile {
56 body: Box<Stmt>,
57 cond: Expr,
58 },
59 Block(Block),
60 Break(Span),
61 Continue(Span),
62 Return(Option<Expr>, Span),
63 Skip(Option<Expr>, Span),
65 Expr(Expr),
66 Value(Expr),
68}