1
Fork 0

add support for a bunch of keyword binary operators

This commit is contained in:
Jake Wheat 2013-12-13 21:41:50 +02:00
parent 546d9b023d
commit b14af47773
2 changed files with 29 additions and 13 deletions
Language/SQL/SimpleSQL

View file

@ -227,7 +227,18 @@ to be.
> ,"||"]
> 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
@ -296,11 +307,16 @@ postgresql handles this
> ,betweenSuffix e0
> ,postfixOp e0
> ] >>= trysuffix
> opSymbol = choice (map (try . symbol) binOpSymbolNames
> ++ map (try . keyword)
> (if bExpr
> then binOpKeywordNamesNoAnd
> else binOpKeywordNames))
> opSymbol = choice
> (map (try . symbol) binOpSymbolNames
> ++ map (try . keywords) binOpMultiKeywordNames
> ++ map (try . keyword)
> (if bExpr
> then binOpKeywordNamesNoAnd
> else binOpKeywordNames))
> keywords ks = intercalate " " <$> keywords' ks
> keywords' [] = return []
> keywords' (k:ks) = (:) <$> keyword k <*> keywords' ks
> sparens :: P ScalarExpr
> sparens = Parens <$> parens scalarExpr'