1
Fork 0

split typed literal parser from cast parser

This commit is contained in:
Jake Wheat 2014-04-17 21:27:54 +03:00
parent df1f948b5d
commit 490c84b7f1

View file

@ -123,6 +123,10 @@ which parses as a typed literal
> mkIt val Nothing = TypedLit (TypeName "interval") val > mkIt val Nothing = TypedLit (TypeName "interval") val
> mkIt val (Just (a,b)) = IntervalLit val a b > mkIt val (Just (a,b)) = IntervalLit val a b
> typedLiteral :: Parser ValueExpr
> typedLiteral = TypedLit <$> typeName
> <*> stringToken
> literal :: Parser ValueExpr > literal :: Parser ValueExpr
> literal = number <|> stringValue <|> interval > literal = number <|> stringValue <|> interval
@ -232,7 +236,7 @@ always used with the optionSuffix combinator.
> windowSuffix _ = fail "" > windowSuffix _ = fail ""
> app :: Name -> Parser ValueExpr > app :: Name -> Parser ValueExpr
> app x = aggOrApp x >>= optionSuffix windowSuffix > app n = aggOrApp n >>= optionSuffix windowSuffix
== iden prefix term == iden prefix term
@ -269,13 +273,9 @@ to separate the arguments.
cast: cast(expr as type) cast: cast(expr as type)
> cast :: Parser ValueExpr > cast :: Parser ValueExpr
> cast = (parensCast <|> prefixCast) > cast = keyword_ "cast" >>
> where > parens (Cast <$> valueExpr
> parensCast = keyword_ "cast" >> > <*> (keyword_ "as" *> typeName))
> parens (Cast <$> valueExpr
> <*> (keyword_ "as" *> typeName))
> prefixCast = try (TypedLit <$> typeName
> <*> stringToken)
the special op keywords the special op keywords
parse an operator which is parse an operator which is
@ -591,6 +591,7 @@ fragile and could at least do with some heavy explanation.
> ,hostParameter > ,hostParameter
> ,caseValue > ,caseValue
> ,cast > ,cast
> ,try typedLiteral
> ,parensTerm > ,parensTerm
> ,subquery > ,subquery
> ,try specialOpKs > ,try specialOpKs