Updated AST.
This commit is contained in:
+47
-47
@@ -1,65 +1,65 @@
|
||||
pub enum Script {
|
||||
pub struct Script {
|
||||
pub items: Vec<Stmt>,
|
||||
}
|
||||
|
||||
pub enum Stmt {
|
||||
Let(Let),
|
||||
Assign(Assign),
|
||||
Expr(Expr),
|
||||
Fn(Fn),
|
||||
Fn(FnDef),
|
||||
}
|
||||
|
||||
pub struct Let {
|
||||
pub name: Ident,
|
||||
pub ty: Option<Type>,
|
||||
pub value: Expr,
|
||||
}
|
||||
|
||||
pub struct Assign {
|
||||
pub name: Ident,
|
||||
pub value: Expr,
|
||||
}
|
||||
|
||||
pub struct FnDef {
|
||||
pub name: Ident,
|
||||
pub params: Vec<FnParam>,
|
||||
pub body: Vec<Stmt>,
|
||||
}
|
||||
|
||||
pub struct FnParam {
|
||||
pub name: Ident,
|
||||
pub ty: Type,
|
||||
}
|
||||
|
||||
pub enum Expr {
|
||||
Literal(Literal),
|
||||
Variable(Ident),
|
||||
FnCall(FnCall),
|
||||
}
|
||||
|
||||
pub struct Expr {
|
||||
pub ident: ExprIdent,
|
||||
pub value: ExprValue,
|
||||
pub enum Literal {
|
||||
Number(LitNumber),
|
||||
String(LitString),
|
||||
}
|
||||
|
||||
pub struct ExprIdent(pub Ident);
|
||||
|
||||
pub enum ExprValue {
|
||||
Number(ExprNumber),
|
||||
String(ExprString),
|
||||
}
|
||||
|
||||
pub struct ExprNumber {
|
||||
pub raw: String,
|
||||
pub struct LitNumber {
|
||||
pub value: f64,
|
||||
}
|
||||
|
||||
pub struct ExprString {
|
||||
pub struct LitString {
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
pub struct Fn {
|
||||
pub ident: FnIdent,
|
||||
pub params: Vec<FnParam>,
|
||||
pub elements: Vec<FnElement>,
|
||||
}
|
||||
|
||||
pub struct FnIdent(pub Ident);
|
||||
|
||||
pub struct FnParam {
|
||||
pub ident: FnParamIdent,
|
||||
pub ty: FnParamType,
|
||||
}
|
||||
|
||||
pub struct FnParamIdent(pub Ident);
|
||||
|
||||
pub enum FnParamType {
|
||||
Number,
|
||||
String,
|
||||
}
|
||||
|
||||
pub enum FnElement {
|
||||
Expr(Expr),
|
||||
}
|
||||
|
||||
pub struct FnCall {
|
||||
pub ident: FnIdent,
|
||||
pub args: Vec<FnCallArg>,
|
||||
}
|
||||
|
||||
pub enum FnCallArg {
|
||||
Expr(ExprIdent),
|
||||
Number(ExprNumber),
|
||||
String(ExprString),
|
||||
pub name: Ident,
|
||||
pub args: Vec<Expr>,
|
||||
}
|
||||
|
||||
pub struct Ident {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
pub enum Type {
|
||||
Number,
|
||||
String,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user