1
0
dust/dust-lang/src/abstract_tree.rs

33 lines
647 B
Rust
Raw Normal View History

2024-08-05 03:11:04 +00:00
use crate::{Identifier, Span, Value};
#[derive(Debug, PartialEq, Clone)]
pub struct Node {
2024-08-05 04:40:51 +00:00
pub statement: Statement,
2024-08-05 03:11:04 +00:00
pub span: Span,
}
impl Node {
pub fn new(operation: Statement, span: Span) -> Self {
2024-08-05 04:40:51 +00:00
Self {
statement: operation,
span,
}
2024-08-05 03:11:04 +00:00
}
}
#[derive(Debug, PartialEq, Clone)]
pub enum Statement {
// Top-level statements
2024-08-05 04:40:51 +00:00
Assign(Box<Node>, Box<Node>),
2024-08-05 03:11:04 +00:00
// Expressions
2024-08-05 04:40:51 +00:00
Add(Box<Node>, Box<Node>),
2024-08-05 18:31:08 +00:00
PropertyAccess(Box<Node>, Box<Node>),
2024-08-05 03:11:04 +00:00
List(Vec<Node>),
2024-08-05 04:40:51 +00:00
Multiply(Box<Node>, Box<Node>),
2024-08-05 03:11:04 +00:00
// Hard-coded values
Constant(Value),
Identifier(Identifier),
}