init
This commit is contained in:
commit
34e45e702f
16 changed files with 1109 additions and 0 deletions
46
src/parser/ast.rs
Normal file
46
src/parser/ast.rs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
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`
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue