refactor the interval literal parser to not use try
This commit is contained in:
parent
556f65ee22
commit
d202458808
|
@ -114,11 +114,14 @@ interval '3 days'
|
||||||
which parses as a typed literal
|
which parses as a typed literal
|
||||||
|
|
||||||
> interval :: Parser ValueExpr
|
> interval :: Parser ValueExpr
|
||||||
> interval = try (keyword_ "interval" >>
|
> interval = keyword_ "interval" >>
|
||||||
> IntervalLit
|
> mkIt <$> stringToken
|
||||||
> <$> stringToken
|
> <*> optionMaybe
|
||||||
> <*> identifierBlacklist blacklist
|
> ((,) <$> identifierBlacklist blacklist
|
||||||
> <*> optionMaybe (parens integer))
|
> <*> optionMaybe (parens integer))
|
||||||
|
> where
|
||||||
|
> mkIt val Nothing = TypedLit (TypeName "interval") val
|
||||||
|
> mkIt val (Just (a,b)) = IntervalLit val a b
|
||||||
|
|
||||||
> literal :: Parser ValueExpr
|
> literal :: Parser ValueExpr
|
||||||
> literal = number <|> stringValue <|> interval
|
> literal = number <|> stringValue <|> interval
|
||||||
|
|
Loading…
Reference in a new issue