mirror of
https://github.com/PaddiM8/kalker.git
synced 2025-03-13 12:58:26 +01:00
24 lines
682 B
Rust
24 lines
682 B
Rust
use crate::lexer::TokenKind;
|
|
|
|
/// A tree structure of a statement.
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub enum Stmt {
|
|
VarDecl(String, Box<Expr>),
|
|
FnDecl(String, Vec<String>, Box<Expr>),
|
|
UnitDecl(String, String, Box<Expr>),
|
|
/// For simplicity, expressions can be put into statements. This is the form in which expressions are passed to the interpreter.
|
|
Expr(Box<Expr>),
|
|
}
|
|
|
|
/// A tree structure of an expression.
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub enum Expr {
|
|
Binary(Box<Expr>, TokenKind, Box<Expr>),
|
|
Unary(TokenKind, Box<Expr>),
|
|
Unit(String, Box<Expr>),
|
|
Var(String),
|
|
Group(Box<Expr>),
|
|
FnCall(String, Vec<Expr>),
|
|
Literal(String),
|
|
}
|