1use crate::error::Span;
2
3#[derive(Debug, Clone, PartialEq)]
4pub struct Program {
5 pub statement: Option<Statement>,
6}
7impl Default for Program {
8 fn default() -> Self {
9 Self::new()
10 }
11}
12
13impl Program {
14 pub fn new() -> Self {
15 Self { statement: None }
16 }
17}
18
19#[derive(Debug, Clone, PartialEq)]
20pub struct Statement {
21 pub kind: StatementKind,
22 pub span: Span,
23}
24
25#[derive(Debug, Clone, PartialEq)]
26pub enum StatementKind {
27 Expression { expr: Expression },
28}
29
30#[derive(Debug, Clone, PartialEq)]
31pub struct Expression {
32 pub kind: ExpressionKind,
33 pub span: Span,
34}
35
36#[derive(Debug, Clone, PartialEq)]
37pub enum ExpressionKind {
38 Dice { count: u32, faces: u32 },
39}
40
41#[derive(Debug, Clone, PartialEq)]
42pub enum BinaryOperator {
43 Dice,
44}
45
46impl Statement {
47 pub fn expr_stmt(expr: Expression, span: Span) -> Self {
48 Self {
49 kind: StatementKind::Expression { expr },
50 span,
51 }
52 }
53}
54
55impl Expression {
56 pub fn dice(count: u32, faces: u32, span: Span) -> Self {
57 Self {
58 kind: ExpressionKind::Dice { count, faces },
59 span,
60 }
61 }
62}