add support for more is ... postfix ops
This commit is contained in:
parent
4f73f4ec44
commit
546d9b023d
|
@ -251,8 +251,22 @@ used for between parsing
|
||||||
|
|
||||||
> postfixOp :: ScalarExpr -> P ScalarExpr
|
> postfixOp :: ScalarExpr -> P ScalarExpr
|
||||||
> postfixOp e =
|
> postfixOp e =
|
||||||
> try $ choice
|
> try $ choice $ map makeOp opPairs
|
||||||
> [PostfixOp "is null" e <$ keyword_ "is" <* keyword_ "null"]
|
> 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' :: P ScalarExpr
|
||||||
> scalarExpr' = scalarExpr'' False
|
> scalarExpr' = scalarExpr'' False
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
> | App String [ScalarExpr]
|
> | App String [ScalarExpr]
|
||||||
> -- the binop, prefixop and postfix op
|
> -- the binop, prefixop and postfix op
|
||||||
> -- are used for symbol and keyword operators
|
> -- are used for symbol and keyword operators
|
||||||
|
> -- these are used even for the multiple keyword
|
||||||
|
> -- operators
|
||||||
> | BinOp String ScalarExpr ScalarExpr
|
> | BinOp String ScalarExpr ScalarExpr
|
||||||
> | PrefixOp String ScalarExpr
|
> | PrefixOp String ScalarExpr
|
||||||
> | PostfixOp String ScalarExpr
|
> | PostfixOp String ScalarExpr
|
||||||
|
|
14
Tests.lhs
14
Tests.lhs
|
@ -154,15 +154,15 @@
|
||||||
> ,Iden "b"
|
> ,Iden "b"
|
||||||
> ,Iden "c"])
|
> ,Iden "c"])
|
||||||
> ,("a is null", PostfixOp "is null" (Iden "a"))
|
> ,("a is null", PostfixOp "is null" (Iden "a"))
|
||||||
> --,("a is not null", Op "not" [])
|
> ,("a is not null", PostfixOp "is not null" (Iden "a"))
|
||||||
|
> ,("a is true", PostfixOp "is true" (Iden "a"))
|
||||||
|
> ,("a is not true", PostfixOp "is not true" (Iden "a"))
|
||||||
|
> ,("a is false", PostfixOp "is false" (Iden "a"))
|
||||||
|
> ,("a is not false", PostfixOp "is not false" (Iden "a"))
|
||||||
|
> ,("a is unknown", PostfixOp "is 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", Op "not" [])
|
||||||
> --,("a is not distinct from b", Op "not" [])
|
> --,("a is not distinct from b", Op "not" [])
|
||||||
> --,("a is true", Op "not" [])
|
|
||||||
> --,("a s not true", Op "not" [])
|
|
||||||
> --,("a is false", Op "not" [])
|
|
||||||
> --,("a is not false", Op "not" [])
|
|
||||||
> --,("a is unknown", Op "not" [])
|
|
||||||
> --,("a is not unknown", Op "not" [])
|
|
||||||
> --,("a like b", Op "not" [])
|
> --,("a like b", Op "not" [])
|
||||||
> --,("a not like b", Op "not" [])
|
> --,("a not like b", Op "not" [])
|
||||||
> --,("a is similar to b", Op "not" [])
|
> --,("a is similar to b", Op "not" [])
|
||||||
|
|
Loading…
Reference in a new issue