tidyups
This commit is contained in:
parent
b14af47773
commit
a001d120c1
|
@ -38,12 +38,9 @@
|
||||||
|
|
||||||
> setPos :: Maybe (Int,Int) -> P ()
|
> setPos :: Maybe (Int,Int) -> P ()
|
||||||
> setPos Nothing = return ()
|
> setPos Nothing = return ()
|
||||||
> setPos (Just (l,c)) =
|
> setPos (Just (l,c)) = fmap f getPosition >>= setPosition
|
||||||
> getPosition
|
> where f = flip setSourceColumn c
|
||||||
> >>= (return
|
> . flip setSourceLine l
|
||||||
> . flip setSourceColumn c
|
|
||||||
> . flip setSourceLine l)
|
|
||||||
> >>= setPosition
|
|
||||||
|
|
||||||
> data ParseError = ParseError
|
> data ParseError = ParseError
|
||||||
> {peErrorString :: String
|
> {peErrorString :: String
|
||||||
|
@ -254,9 +251,8 @@ used for between parsing
|
||||||
|
|
||||||
> prefixUnaryOp :: P ScalarExpr
|
> prefixUnaryOp :: P ScalarExpr
|
||||||
> prefixUnaryOp =
|
> prefixUnaryOp =
|
||||||
> makeOp <$> opSymbol <*> scalarExpr'
|
> PrefixOp <$> opSymbol <*> scalarExpr'
|
||||||
> where
|
> where
|
||||||
> makeOp nm e = PrefixOp nm e
|
|
||||||
> opSymbol = choice (map (try . symbol) prefixUnOpSymbolNames
|
> opSymbol = choice (map (try . symbol) prefixUnOpSymbolNames
|
||||||
> ++ map (try . keyword) prefixUnOpKeywordNames)
|
> ++ map (try . keyword) prefixUnOpKeywordNames)
|
||||||
|
|
||||||
|
@ -276,8 +272,7 @@ used for between parsing
|
||||||
> opPairs = flip map ops $ \o -> (o, words o)
|
> opPairs = flip map ops $ \o -> (o, words o)
|
||||||
> makeOp (o,ws) =
|
> makeOp (o,ws) =
|
||||||
> try $ PostfixOp o e <$ keywords_ ws
|
> try $ PostfixOp o e <$ keywords_ ws
|
||||||
> keywords_ [] = return ()
|
> keywords_ = try . mapM_ keyword_
|
||||||
> keywords_ (k:ks) = keyword_ k <* keywords_ ks
|
|
||||||
|
|
||||||
> scalarExpr' :: P ScalarExpr
|
> scalarExpr' :: P ScalarExpr
|
||||||
> scalarExpr' = scalarExpr'' False
|
> scalarExpr' = scalarExpr'' False
|
||||||
|
@ -294,6 +289,7 @@ postgresql handles this
|
||||||
> factor = choice [literal
|
> factor = choice [literal
|
||||||
> ,scase
|
> ,scase
|
||||||
> ,cast
|
> ,cast
|
||||||
|
> --,extract
|
||||||
> ,subquery
|
> ,subquery
|
||||||
> ,prefixUnaryOp
|
> ,prefixUnaryOp
|
||||||
> ,try app
|
> ,try app
|
||||||
|
@ -314,9 +310,7 @@ postgresql handles this
|
||||||
> (if bExpr
|
> (if bExpr
|
||||||
> then binOpKeywordNamesNoAnd
|
> then binOpKeywordNamesNoAnd
|
||||||
> else binOpKeywordNames))
|
> else binOpKeywordNames))
|
||||||
> keywords ks = intercalate " " <$> keywords' ks
|
> keywords ks = unwords <$> mapM keyword ks
|
||||||
> keywords' [] = return []
|
|
||||||
> keywords' (k:ks) = (:) <$> keyword k <*> keywords' ks
|
|
||||||
|
|
||||||
> sparens :: P ScalarExpr
|
> sparens :: P ScalarExpr
|
||||||
> sparens = Parens <$> parens scalarExpr'
|
> sparens = Parens <$> parens scalarExpr'
|
||||||
|
|
|
@ -44,8 +44,8 @@ back into SQL source text. It attempts to format the output nicely.
|
||||||
> sep [scalarExpr e0, text f, scalarExpr e1]
|
> sep [scalarExpr e0, text f, scalarExpr e1]
|
||||||
|
|
||||||
> scalarExpr (Case t ws els) =
|
> scalarExpr (Case t ws els) =
|
||||||
> sep [text "case" <+> (maybe empty scalarExpr t)
|
> sep [text "case" <+> maybe empty scalarExpr t
|
||||||
> ,nest 4 (sep ((map w ws)
|
> ,nest 4 (sep (map w ws
|
||||||
> ++ maybeToList (fmap e els)))
|
> ++ maybeToList (fmap e els)))
|
||||||
> ,text "end"]
|
> ,text "end"]
|
||||||
> where
|
> where
|
||||||
|
|
1
TODO
1
TODO
|
@ -8,6 +8,7 @@ get tpch parsing
|
||||||
check the pretty printer on the tpch queries
|
check the pretty printer on the tpch queries
|
||||||
add automated tests to cabal
|
add automated tests to cabal
|
||||||
do code documentation and haddock
|
do code documentation and haddock
|
||||||
|
check the order of exports, imports and functions/cases in the files
|
||||||
do some tests for parse errors?
|
do some tests for parse errors?
|
||||||
website with haddock and table of parsing tests
|
website with haddock and table of parsing tests
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@
|
||||||
> ,("a is similar to b", BinOp "is similar to" (Iden "a") (Iden "b"))
|
> ,("a is similar to b", BinOp "is similar to" (Iden "a") (Iden "b"))
|
||||||
> ,("a is not similar to b", BinOp "is not similar to" (Iden "a") (Iden "b"))
|
> ,("a is not similar to b", BinOp "is not similar to" (Iden "a") (Iden "b"))
|
||||||
> ,("a overlaps b", BinOp "overlaps" (Iden "a") (Iden "b"))
|
> ,("a overlaps b", BinOp "overlaps" (Iden "a") (Iden "b"))
|
||||||
> --,("extract(day from t)", Op "not" [])
|
> --,("extract(day from t)", SpecialOp "extract" [Iden "day", Iden "t"])
|
||||||
> ]
|
> ]
|
||||||
|
|
||||||
> aggregates :: TestItem
|
> aggregates :: TestItem
|
||||||
|
|
Loading…
Reference in a new issue