add support for a bunch of keyword binary operators
This commit is contained in:
parent
546d9b023d
commit
b14af47773
|
@ -227,7 +227,18 @@ to be.
|
||||||
> ,"||"]
|
> ,"||"]
|
||||||
|
|
||||||
> binOpKeywordNames :: [String]
|
> binOpKeywordNames :: [String]
|
||||||
> binOpKeywordNames = ["and", "or", "like"]
|
> binOpKeywordNames = ["and", "or", "like"
|
||||||
|
> ,"overlaps"]
|
||||||
|
|
||||||
|
> binOpMultiKeywordNames :: [[String]]
|
||||||
|
> binOpMultiKeywordNames = map words
|
||||||
|
> ["not like"
|
||||||
|
> ,"not similar"
|
||||||
|
> ,"is similar to"
|
||||||
|
> ,"is not similar to"
|
||||||
|
> ,"is distinct from"
|
||||||
|
> ,"is not distinct from"]
|
||||||
|
|
||||||
|
|
||||||
used for between parsing
|
used for between parsing
|
||||||
|
|
||||||
|
@ -296,11 +307,16 @@ postgresql handles this
|
||||||
> ,betweenSuffix e0
|
> ,betweenSuffix e0
|
||||||
> ,postfixOp e0
|
> ,postfixOp e0
|
||||||
> ] >>= trysuffix
|
> ] >>= trysuffix
|
||||||
> opSymbol = choice (map (try . symbol) binOpSymbolNames
|
> opSymbol = choice
|
||||||
> ++ map (try . keyword)
|
> (map (try . symbol) binOpSymbolNames
|
||||||
> (if bExpr
|
> ++ map (try . keywords) binOpMultiKeywordNames
|
||||||
> then binOpKeywordNamesNoAnd
|
> ++ map (try . keyword)
|
||||||
> else binOpKeywordNames))
|
> (if bExpr
|
||||||
|
> then binOpKeywordNamesNoAnd
|
||||||
|
> else binOpKeywordNames))
|
||||||
|
> keywords ks = intercalate " " <$> keywords' ks
|
||||||
|
> keywords' [] = return []
|
||||||
|
> keywords' (k:ks) = (:) <$> keyword k <*> keywords' ks
|
||||||
|
|
||||||
> sparens :: P ScalarExpr
|
> sparens :: P ScalarExpr
|
||||||
> sparens = Parens <$> parens scalarExpr'
|
> sparens = Parens <$> parens scalarExpr'
|
||||||
|
|
14
Tests.lhs
14
Tests.lhs
|
@ -161,13 +161,13 @@
|
||||||
> ,("a is not false", PostfixOp "is not false" (Iden "a"))
|
> ,("a is not false", PostfixOp "is not false" (Iden "a"))
|
||||||
> ,("a is unknown", PostfixOp "is unknown" (Iden "a"))
|
> ,("a is unknown", PostfixOp "is unknown" (Iden "a"))
|
||||||
> ,("a is not unknown", PostfixOp "is not unknown" (Iden "a"))
|
> ,("a is not unknown", PostfixOp "is not unknown" (Iden "a"))
|
||||||
> --,("a is distinct from b", Op "not" [])
|
> ,("a is distinct from b", BinOp "is distinct from" (Iden "a") (Iden "b"))
|
||||||
> --,("a is not distinct from b", Op "not" [])
|
> ,("a is not distinct from b", BinOp "is not distinct from" (Iden "a") (Iden "b"))
|
||||||
> --,("a like b", Op "not" [])
|
> ,("a like b", BinOp "like" (Iden "a") (Iden "b"))
|
||||||
> --,("a not like b", Op "not" [])
|
> ,("a not like b", BinOp "not like" (Iden "a") (Iden "b"))
|
||||||
> --,("a is similar to b", Op "not" [])
|
> ,("a is similar to b", BinOp "is similar to" (Iden "a") (Iden "b"))
|
||||||
> --,("a is not similar to b", Op "not" [])
|
> ,("a is not similar to b", BinOp "is not similar to" (Iden "a") (Iden "b"))
|
||||||
> --,("a overlaps b", Op "not" [])
|
> ,("a overlaps b", BinOp "overlaps" (Iden "a") (Iden "b"))
|
||||||
> --,("extract(day from t)", Op "not" [])
|
> --,("extract(day from t)", Op "not" [])
|
||||||
> ]
|
> ]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue