76 lines
1.1 KiB
Rust
76 lines
1.1 KiB
Rust
use crate::tokens::Position;
|
|
|
|
#[derive(Debug)]
|
|
pub struct Node<T> {
|
|
pub value: T,
|
|
pub pos: Position,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum Expr {
|
|
Unit,
|
|
Id(String),
|
|
Int(i64),
|
|
Float(f64),
|
|
String(String),
|
|
Bool(bool),
|
|
Array(Vec<Node<Expr>>),
|
|
Object(Vec<ObjectEntry>),
|
|
Tuple(Vec<Node<Expr>>),
|
|
|
|
Member {
|
|
subject: Box<Node<Expr>>,
|
|
value: String,
|
|
},
|
|
Index {
|
|
subject: Box<Node<Expr>>,
|
|
value: Box<Node<Expr>>,
|
|
},
|
|
Call {
|
|
subject: Box<Node<Expr>>,
|
|
arguments: Vec<Node<Expr>>,
|
|
},
|
|
Unary {
|
|
unary_type: UnaryType,
|
|
subject: Box<Node<Expr>>,
|
|
},
|
|
Binary {
|
|
binary_type: BinaryType,
|
|
left: Box<Node<Expr>>,
|
|
right: Box<Node<Expr>>,
|
|
},
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum ObjectEntry {
|
|
Pair(Box<Node<Expr>>, Box<Expr>),
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum UnaryType {
|
|
Not,
|
|
Negate,
|
|
Reference,
|
|
ReferenceMut,
|
|
Dereference,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum BinaryType {
|
|
Exponentiate,
|
|
Multiply,
|
|
Divide,
|
|
Modulo,
|
|
Add,
|
|
Subtract,
|
|
LT,
|
|
LTE,
|
|
GT,
|
|
GTE,
|
|
In,
|
|
Equal,
|
|
Inequal,
|
|
And,
|
|
Or,
|
|
}
|