factorio_ir/
expression.rs1use crate::{block::Block, literal::Literal, operator::Operator};
2
3#[derive(Debug, PartialEq, Clone)]
4pub enum Expression {
5 Literal(Literal),
6 Identifier(String),
7 QualifiedPath {
8 segments: Vec<String>,
9 },
10 FieldAccess {
11 base: Box<Self>,
12 field: String,
13 },
14 Call {
15 func: Box<Self>,
16 args: Vec<Self>,
17 },
18 MethodCall {
19 receiver: Box<Self>,
20 method: String,
21 args: Vec<Self>,
22 },
23 StructLiteral {
24 struct_name: Option<String>,
27 fields: Vec<(String, Self)>,
28 },
29 BinaryOp {
31 lhs: Box<Self>,
32 op: Operator,
33 rhs: Box<Self>,
34 },
35 FormatConcat {
37 parts: Vec<Self>,
38 },
39 Array {
41 elements: Vec<Self>,
42 },
43 Index {
45 base: Box<Self>,
46 key: Box<Self>,
47 },
48 Not(Box<Self>),
50 Len(Box<Self>),
52 If {
54 condition: Box<Self>,
55 then_expr: Box<Self>,
56 else_expr: Box<Self>,
57 },
58 Closure {
60 params: Vec<String>,
61 body: Block,
62 },
63}