2020-05-30 15:27:58 +02:00
|
|
|
use crate::lexer::TokenKind;
|
|
|
|
|
2020-06-11 23:09:44 +02:00
|
|
|
/// A tree structure of a statement.
|
2020-06-05 13:36:11 +02:00
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
2020-05-30 15:27:58 +02:00
|
|
|
pub enum Stmt {
|
|
|
|
VarDecl(String, Box<Expr>),
|
|
|
|
FnDecl(String, Vec<String>, Box<Expr>),
|
2020-06-13 16:19:32 +02:00
|
|
|
UnitDecl(String, String, Box<Expr>),
|
2020-06-11 23:09:44 +02:00
|
|
|
/// For simplicity, expressions can be put into statements. This is the form in which expressions are passed to the interpreter.
|
2020-05-30 15:27:58 +02:00
|
|
|
Expr(Box<Expr>),
|
|
|
|
}
|
|
|
|
|
2020-06-11 23:09:44 +02:00
|
|
|
/// A tree structure of an expression.
|
2020-06-05 13:36:11 +02:00
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
2020-05-30 15:27:58 +02:00
|
|
|
pub enum Expr {
|
|
|
|
Binary(Box<Expr>, TokenKind, Box<Expr>),
|
|
|
|
Unary(TokenKind, Box<Expr>),
|
2020-06-13 16:19:32 +02:00
|
|
|
Unit(String, Box<Expr>),
|
2020-05-30 15:27:58 +02:00
|
|
|
Var(String),
|
|
|
|
Group(Box<Expr>),
|
|
|
|
FnCall(String, Vec<Expr>),
|
|
|
|
Literal(String),
|
|
|
|
}
|