-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathast.rs
More file actions
52 lines (44 loc) · 986 Bytes
/
ast.rs
File metadata and controls
52 lines (44 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#[derive(Debug, Clone)]
pub enum Value {
Int(i64),
Text(String),
}
#[derive(Debug, Clone)]
pub enum ASTNode {
Function(FunctionNode),
}
#[derive(Debug, Clone)]
pub struct FunctionNode {
pub name: String,
pub parameters: Vec<ParameterNode>,
pub body: Vec<ASTNode>,
}
#[derive(Debug, Clone)]
pub struct ParameterNode {
pub name: String,
pub param_type: String, // For simplicity, assuming type as string.
}
pub fn create_function_ast(function_name: String) -> ASTNode {
ASTNode::Function(FunctionNode {
name: function_name,
parameters: vec![], // No parameters
body: vec![], // Empty body
})
}
/*
#[derive(Debug, Clone)]
pub struct AST {
pub nodes: Vec<ASTNode>,
}
impl AST {
pub fn new() -> Self {
AST {
nodes: Vec::new()
}
}
pub fn add_node(&mut self, node: ASTNode) {
eprintln!("Adding node to AST: {:?}", node);
self.nodes.push(node);
}
}
*/