Skip to content

Commit

Permalink
added a check to make sure the age ranges are the right way around
Browse files Browse the repository at this point in the history
  • Loading branch information
nevrome committed Nov 20, 2023
1 parent 5d8d603 commit a495386
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Currycarbon/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit a495386

Please sign in to comment.