1
Fork 0

refactor the interval literal parser to not use try

This commit is contained in:
Jake Wheat 2014-04-17 20:53:16 +03:00
parent 556f65ee22
commit d202458808

View file

@ -114,11 +114,14 @@ interval '3 days'
which parses as a typed literal
> interval :: Parser ValueExpr
> interval = try (keyword_ "interval" >>
> IntervalLit
> <$> stringToken
> <*> identifierBlacklist blacklist
> <*> optionMaybe (parens integer))
> interval = keyword_ "interval" >>
> mkIt <$> stringToken
> <*> optionMaybe
> ((,) <$> identifierBlacklist blacklist
> <*> optionMaybe (parens integer))
> where
> mkIt val Nothing = TypedLit (TypeName "interval") val
> mkIt val (Just (a,b)) = IntervalLit val a b
> literal :: Parser ValueExpr
> literal = number <|> stringValue <|> interval