46 lines
1.2 KiB
Rust
46 lines
1.2 KiB
Rust
use std::collections::HashMap;
|
|
|
|
pub struct Ast {
|
|
program: Vec<Statement>,
|
|
}
|
|
|
|
pub enum Statement {
|
|
Open(String), // TODO: parse into `OpenTree`
|
|
Definition {
|
|
is_public: bool,
|
|
ident: String,
|
|
generics: Vec<Expression>, // TODO: refine
|
|
definition_kind: crate::token::Kind,
|
|
definition: Expression,
|
|
},
|
|
Module {
|
|
is_public: bool,
|
|
ident: String,
|
|
definition: Vec<Statement>,
|
|
},
|
|
Comment(String), // TODO: differentiate kinds
|
|
}
|
|
|
|
pub enum Expression {
|
|
Function {
|
|
args: Vec<Expression>, // TODO: get more granular
|
|
body: Vec<Statement>,
|
|
},
|
|
Application {
|
|
function: Box<Expression>,
|
|
args: Vec<Expression>,
|
|
},
|
|
BinOp {
|
|
operands: Box<(Expression, Expression)>,
|
|
operator: Box<Expression>, // TODO: refine? (maybe we _want_ arbitrary binary operators)
|
|
},
|
|
Type(Vec<Type>),
|
|
GenericSpecification(Vec<Expression>), // TODO: refine
|
|
}
|
|
|
|
pub enum Type {
|
|
Record(HashMap<String, String>), // { red: u8, green: u8, blue: u8 }
|
|
Tuple(Vec<String>), // `Some (T) | None`
|
|
Simple(String), // `Option::Some (T)`
|
|
Empty, // `Option::None`
|
|
}
|