1use wasmly::DataType;
2
3#[derive(Debug)]
4pub struct App {
5 pub children: Vec<TopLevelOperation>,
6}
7
8#[derive(Debug, Clone)]
9pub enum TopLevelOperation {
10 Comment(String),
11 DefineGlobal(Global),
12 DefineFunction(FunctionDefinition),
13 ExternalFunction(ExternalFunction),
14}
15
16#[derive(Debug, Clone)]
17pub struct Global {
18 pub name: String,
19 pub value: GlobalValue,
20}
21
22#[derive(Debug, Clone)]
23pub enum GlobalValue {
24 Symbol(String),
25 Number(f64),
26 Text(String),
27 Data(Vec<GlobalValue>),
28 Identifier(String),
29 Struct(StructDefinition),
30}
31
32#[derive(Debug, Clone)]
33pub struct ExternalFunction {
34 pub name: String,
35 pub params: Vec<String>,
36}
37
38#[derive(Debug, Clone)]
39pub struct FunctionDefinition {
40 pub name: String,
41 pub exported: bool,
42 pub params: Vec<String>,
43 pub output: Option<String>,
44 pub children: Vec<Expression>,
45}
46
47#[derive(Debug, Clone)]
48pub struct StructMember {
49 pub name: String,
50}
51
52#[derive(Debug, Clone)]
53pub struct StructDefinition {
54 pub members: Vec<StructMember>,
55}
56
57#[derive(Debug, Clone)]
58pub struct OperationFunctionCall {
59 pub function_name: String,
60 pub params: Vec<Expression>,
61}
62
63#[derive(Debug, Clone)]
64pub struct OperationRecur {}
65
66#[derive(Debug, Clone)]
67pub struct OperationAssignment {
68 pub id: String,
69 pub value: Box<Expression>,
70}
71
72#[derive(Debug, Clone)]
73pub struct OperationIfStatement {
74 pub condition: Box<Expression>,
75 pub if_true: Vec<Expression>,
76 pub if_false: Option<Vec<Expression>>,
77}
78
79#[derive(Debug, Clone)]
80pub struct OperationLoop {
81 pub expressions: Vec<Expression>,
82}
83
84#[derive(Debug, Clone)]
85pub struct OperationFnSig {
86 pub inputs: Vec<DataType>,
87 pub output: Option<DataType>,
88}
89
90#[derive(Debug, Clone)]
91pub enum Expression {
92 IfStatement(OperationIfStatement),
93 Assignment(OperationAssignment),
94 TextLiteral(String),
95 SymbolLiteral(String),
96 Identifier(String),
97 FunctionCall(OperationFunctionCall),
98 Number(f64),
99 Recur(OperationRecur),
100 Loop(OperationLoop),
101 FnSig(OperationFnSig),
102}