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 EnumLiteral {
31 enum_name: String,
32 variant: String,
33 fields: Vec<(String, Self)>,
35 },
36 BinaryOp {
38 lhs: Box<Self>,
39 op: Operator,
40 rhs: Box<Self>,
41 },
42 FormatConcat {
44 parts: Vec<Self>,
45 },
46 Array {
48 elements: Vec<Self>,
49 },
50 Index {
52 base: Box<Self>,
53 key: Box<Self>,
54 },
55 Not(Box<Self>),
57 Len(Box<Self>),
59 If {
61 condition: Box<Self>,
62 then_expr: Box<Self>,
63 else_expr: Box<Self>,
64 },
65 Closure {
67 params: Vec<String>,
68 body: Block,
69 },
70}