From a495386ec95e80813f34a1e02bbedbc636ff653f Mon Sep 17 00:00:00 2001 From: Clemens Schmid Date: Mon, 20 Nov 2023 11:22:38 +0100 Subject: [PATCH] added a check to make sure the age ranges are the right way around --- src/Currycarbon/Parsers.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Currycarbon/Parsers.hs b/src/Currycarbon/Parsers.hs index 67c8249..55fc3b6 100644 --- a/src/Currycarbon/Parsers.hs +++ b/src/Currycarbon/Parsers.hs @@ -118,7 +118,9 @@ parseTimeWindowBP = do start <- parsePositiveInteger _ <- P.spaces *> P.string "<-|" <* P.spaces stop <- parsePositiveInteger - return (TimeWindowBP name start stop) + if start >= stop + then return (TimeWindowBP name start stop) + else fail "the BP stop date can not be larger then the start date" parseTimeWindowBCAD :: P.Parser TimeWindowBCAD parseTimeWindowBCAD = do @@ -127,7 +129,9 @@ parseTimeWindowBCAD = do start <- parseInteger _ <- P.spaces *> P.string "<+>" <* P.spaces stop <- parseInteger - return (TimeWindowBCAD name start stop) + if start <= stop + then return (TimeWindowBCAD name start stop) + else fail "the BC/AD stop date can not be smaller then the start date" add :: P.Parser CalExpr add = SumCal <$> term <*> (spaceChar '+' *> expr)