use crate::token::Span; #[derive(Debug, PartialEq, Eq)] pub struct Expression { pub kind: ExpressionKind, pub span: Span, } #[derive(Debug, PartialEq, Eq)] pub enum ExpressionKind { Integer(u64), Boolean(bool), Identifier(Box), Unary { op: UnaryOp, op_span: Span, expr: Box, }, Binary { op: BinaryOp, op_span: Span, left: Box, right: Box, }, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum UnaryOp { LogicalNot, BitwiseNot, Negate, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum BinaryOp { Add, Subtract, Multiply, Divide, Remainder, BitwiseAnd, BitwiseOr, BitwiseXor, LogicalAnd, LogicalOr, Equal, Unequal, LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual, Assign, Member, } #[derive(Debug, PartialEq, Eq)] pub enum Statement { Let { name: Box, name_span: Span, type_: Option, value: Option, }, If { kw_span: Span, condition: Expression, then: Box, elze: Option>, }, Loop { kw_span: Span, body: Box, }, Break { kw_span: Span, }, Return { kw_span: Span, value: Option, }, Compound { body: Vec, }, Expr(Expression), } #[derive(Debug, PartialEq, Eq)] pub enum Type { Integer { size: u8, signed: bool }, Boolean, Named { name: Box, name_span: Span }, } #[derive(Debug, PartialEq, Eq)] pub enum Declaration { Function { name: Box, name_span: Span, parameters: Vec, return_type: Option, body: Option, }, } #[derive(Debug, PartialEq, Eq)] pub struct Parameter { pub name: Box, pub name_span: Span, pub type_: Type, }