add support for more is ... postfix ops
This commit is contained in:
parent
4f73f4ec44
commit
546d9b023d
3 changed files with 25 additions and 9 deletions
Language/SQL/SimpleSQL
|
@ -251,8 +251,22 @@ used for between parsing
|
|||
|
||||
> postfixOp :: ScalarExpr -> P ScalarExpr
|
||||
> postfixOp e =
|
||||
> try $ choice
|
||||
> [PostfixOp "is null" e <$ keyword_ "is" <* keyword_ "null"]
|
||||
> try $ choice $ map makeOp opPairs
|
||||
> where
|
||||
> -- could left factor here?
|
||||
> ops = ["is null"
|
||||
> ,"is not null"
|
||||
> ,"is true"
|
||||
> ,"is not true"
|
||||
> ,"is false"
|
||||
> ,"is not false"
|
||||
> ,"is unknown"
|
||||
> ,"is not unknown"]
|
||||
> opPairs = flip map ops $ \o -> (o, words o)
|
||||
> makeOp (o,ws) =
|
||||
> try $ PostfixOp o e <$ keywords_ ws
|
||||
> keywords_ [] = return ()
|
||||
> keywords_ (k:ks) = keyword_ k <* keywords_ ks
|
||||
|
||||
> scalarExpr' :: P ScalarExpr
|
||||
> scalarExpr' = scalarExpr'' False
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
> | App String [ScalarExpr]
|
||||
> -- the binop, prefixop and postfix op
|
||||
> -- are used for symbol and keyword operators
|
||||
> -- these are used even for the multiple keyword
|
||||
> -- operators
|
||||
> | BinOp String ScalarExpr ScalarExpr
|
||||
> | PrefixOp String ScalarExpr
|
||||
> | PostfixOp String ScalarExpr
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue