diff --git a/src/commands.rs b/src/commands.rs index 08ed3de..fbc90a8 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,4 +1,4 @@ -use chrono::{NaiveDate, NaiveDateTime}; +use chrono::NaiveDate; #[derive(Debug)] pub struct Time { @@ -76,7 +76,7 @@ pub struct WeekdaySpec { } #[derive(Debug)] -pub enum IntVar { +pub enum Var { /// `j`, see JulianDay, /// `y` @@ -141,24 +141,6 @@ pub enum IntVar { Saturday, /// `sun`, always 7 Sunday, -} - -#[derive(Debug)] -pub enum IntExpr { - Lit(i64), - Var(IntVar), - Paren(Box), - Neg(Box), - Add(Box, Box), - Sub(Box, Box), - Mul(Box, Box), - Div(Box, Box), - Mod(Box, Box), - Ternary(Box, Box, Box), -} - -#[derive(Debug)] -pub enum BoolVar { /// `isWeekday`, whether the current day is one of mon-fri IsWeekday, /// `isWeekend`, whether the current day is one of sat-sun @@ -168,27 +150,34 @@ pub enum BoolVar { } #[derive(Debug)] -pub enum BoolExpr { - Lit(bool), - Var(BoolVar), - Paren(Box), - Eq(Box, Box), - Neq(Box, Box), - Lt(Box, Box), - Lte(Box, Box), - Gt(Box, Box), - Gte(Box, Box), - Not(Box), - And(Box, Box), - Or(Box, Box), - Xor(Box, Box), - BEq(Box, Box), - BNeq(Box, Box), +pub enum Expr { + Lit(i64), + Var(Var), + Paren(Box), + // Integer-y operations + Neg(Box), + Add(Box, Box), + Sub(Box, Box), + Mul(Box, Box), + Div(Box, Box), + Mod(Box, Box), + // Comparisons + Eq(Box, Box), + Neq(Box, Box), + Lt(Box, Box), + Lte(Box, Box), + Gt(Box, Box), + Gte(Box, Box), + // Boolean-y operations + Not(Box), + And(Box, Box), + Or(Box, Box), + Xor(Box, Box), } #[derive(Debug)] pub struct FormulaSpec { - pub start: Option, // None: * + pub start: Option, // None: * pub start_delta: Option, pub start_time: Option