Daniel M 41b7247ffd Implement some statements
- Impl. expression only statement (expr;)
- Impl. let binding ("let" ident "=" expr;)
- Impl. assignment (ident "=" expr;)
2021-12-24 01:48:18 +01:00

42 lines
841 B
Rust

use crate::token::Literal;
/// Binary Operator Types. For operations that have two operands
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum BinOpType {
Add,
Sub,
Mul,
Div,
Mod
}
/// Unary Operator Types. For operations that have one operand
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum UnOpType {
Neg
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FnCall {
pub fn_name: String,
pub args: Vec<Expr>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Expr {
Literal(Literal),
// contains variable name
Variable(String),
FnCall(FnCall),
BinOp(BinOpType, Box<Expr>, Box<Expr>),
UnOp(UnOpType, Box<Expr>),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Statement {
Expr(Expr),
LetBinding(String, Expr),
Assignment(String, Expr),
}