few small typos, etc.
This commit is contained in:
parent
b6633bf73c
commit
3fa7086a48
|
@ -88,13 +88,13 @@ the fixity code.
|
||||||
> HSE.App (var ('a':nm))
|
> HSE.App (var ('a':nm))
|
||||||
> $ HSE.List [str $ show (d,map snd od)
|
> $ HSE.List [str $ show (d,map snd od)
|
||||||
> ,HSE.List $ map toHaskell es
|
> ,HSE.List $ map toHaskell es
|
||||||
> ,HSE.List $ map toHaskell $ map fst od]
|
> ,HSE.List $ map (toHaskell . fst) od]
|
||||||
> WindowApp nm es pb od ->
|
> WindowApp nm es pb od ->
|
||||||
> HSE.App (var ('w':nm))
|
> HSE.App (var ('w':nm))
|
||||||
> $ HSE.List [str $ show (map snd od)
|
> $ HSE.List [str $ show (map snd od)
|
||||||
> ,HSE.List $ map toHaskell es
|
> ,HSE.List $ map toHaskell es
|
||||||
> ,HSE.List $ map toHaskell pb
|
> ,HSE.List $ map toHaskell pb
|
||||||
> ,HSE.List $ map toHaskell $ map fst od]
|
> ,HSE.List $ map (toHaskell . fst) od]
|
||||||
> PrefixOp nm e0 ->
|
> PrefixOp nm e0 ->
|
||||||
> HSE.App (HSE.Var $ sym nm) (toHaskell e0)
|
> HSE.App (HSE.Var $ sym nm) (toHaskell e0)
|
||||||
> PostfixOp nm e0 ->
|
> PostfixOp nm e0 ->
|
||||||
|
|
|
@ -16,26 +16,26 @@
|
||||||
> import Language.SQL.SimpleSQL.Syntax
|
> import Language.SQL.SimpleSQL.Syntax
|
||||||
> import Language.SQL.SimpleSQL.Fixity
|
> import Language.SQL.SimpleSQL.Fixity
|
||||||
|
|
||||||
The public api functions.
|
The public API functions.
|
||||||
|
|
||||||
> -- | Parses a query expr, trailing semicolon optional.
|
> -- | Parses a query expr, trailing semicolon optional.
|
||||||
> parseQueryExpr :: FilePath -- ^ filename to use in errors
|
> parseQueryExpr :: FilePath -- ^ filename to use in errors
|
||||||
> -> Maybe (Int,Int) -- ^ line number and column number to use in errors
|
> -> Maybe (Int,Int) -- ^ line number and column number to use in errors
|
||||||
> -> String -- ^ the sql source to parse
|
> -> String -- ^ the SQL source to parse
|
||||||
> -> Either ParseError QueryExpr
|
> -> Either ParseError QueryExpr
|
||||||
> parseQueryExpr = wrapParse topLevelQueryExpr
|
> parseQueryExpr = wrapParse topLevelQueryExpr
|
||||||
|
|
||||||
> -- | Parses a list of query exprs, with semi colons between them. The final semicolon is optional.
|
> -- | Parses a list of query exprs, with semi colons between them. The final semicolon is optional.
|
||||||
> parseQueryExprs :: FilePath -- ^ filename to use in errors
|
> parseQueryExprs :: FilePath -- ^ filename to use in errors
|
||||||
> -> Maybe (Int,Int) -- ^ line number and column number to use in errors
|
> -> Maybe (Int,Int) -- ^ line number and column number to use in errors
|
||||||
> -> String -- ^ the sql source to parse
|
> -> String -- ^ the SQL source to parse
|
||||||
> -> Either ParseError [QueryExpr]
|
> -> Either ParseError [QueryExpr]
|
||||||
> parseQueryExprs = wrapParse queryExprs
|
> parseQueryExprs = wrapParse queryExprs
|
||||||
|
|
||||||
> -- | Parses a scalar expression.
|
> -- | Parses a scalar expression.
|
||||||
> parseScalarExpr :: FilePath -- ^ filename to use in errors
|
> parseScalarExpr :: FilePath -- ^ filename to use in errors
|
||||||
> -> Maybe (Int,Int) -- ^ line number and column number to use in errors
|
> -> Maybe (Int,Int) -- ^ line number and column number to use in errors
|
||||||
> -> String -- ^ the sql source to parse
|
> -> String -- ^ the SQL source to parse
|
||||||
> -> Either ParseError ScalarExpr
|
> -> Either ParseError ScalarExpr
|
||||||
> parseScalarExpr = wrapParse scalarExpr
|
> parseScalarExpr = wrapParse scalarExpr
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ aggregate([all|distinct] args [order by orderitems])
|
||||||
|
|
||||||
parse a window call as a suffix of a regular function call
|
parse a window call as a suffix of a regular function call
|
||||||
this looks like this:
|
this looks like this:
|
||||||
functioncall(args) over ([partition by ids] [order by orderitems])
|
functionname(args) over ([partition by ids] [order by orderitems])
|
||||||
|
|
||||||
No support for explicit frames yet.
|
No support for explicit frames yet.
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ The parsers:
|
||||||
> keywords_ = try . mapM_ keyword_
|
> keywords_ = try . mapM_ keyword_
|
||||||
|
|
||||||
All the binary operators are parsed as same precedence and left
|
All the binary operators are parsed as same precedence and left
|
||||||
associativity. This is fixed with a separate pass over the ast.
|
associativity. This is fixed with a separate pass over the AST.
|
||||||
|
|
||||||
> binaryOperatorSuffix :: Bool -> ScalarExpr -> P ScalarExpr
|
> binaryOperatorSuffix :: Bool -> ScalarExpr -> P ScalarExpr
|
||||||
> binaryOperatorSuffix bExpr e0 =
|
> binaryOperatorSuffix bExpr e0 =
|
||||||
|
@ -381,7 +381,7 @@ associativity. This is fixed with a separate pass over the ast.
|
||||||
> sqlFixities = highPrec ++ defaultPrec ++ lowPrec
|
> sqlFixities = highPrec ++ defaultPrec ++ lowPrec
|
||||||
> where
|
> where
|
||||||
> allOps = binOpSymbolNames ++ binOpKeywordNames
|
> allOps = binOpSymbolNames ++ binOpKeywordNames
|
||||||
> ++ (map unwords binOpMultiKeywordNames)
|
> ++ map unwords binOpMultiKeywordNames
|
||||||
> ++ prefixUnOpKeywordNames ++ prefixUnOpSymbolNames
|
> ++ prefixUnOpKeywordNames ++ prefixUnOpSymbolNames
|
||||||
> ++ postfixOpKeywords
|
> ++ postfixOpKeywords
|
||||||
> -- these are the ops with the highest precedence in order
|
> -- these are the ops with the highest precedence in order
|
||||||
|
@ -498,7 +498,7 @@ tref
|
||||||
> $ commaSep1 identifierString
|
> $ commaSep1 identifierString
|
||||||
> in option j (TRAlias j <$> try tableAlias <*> try columnAliases)
|
> in option j (TRAlias j <$> try tableAlias <*> try columnAliases)
|
||||||
> joinTrefSuffix t = (do
|
> joinTrefSuffix t = (do
|
||||||
> nat <- option False $ try (True <$ (try $ keyword_ "natural"))
|
> nat <- option False $ try (True <$ try (keyword_ "natural"))
|
||||||
> TRJoin t <$> joinType
|
> TRJoin t <$> joinType
|
||||||
> <*> nonJoinTref
|
> <*> nonJoinTref
|
||||||
> <*> optionMaybe (joinCondition nat))
|
> <*> optionMaybe (joinCondition nat))
|
||||||
|
@ -610,8 +610,8 @@ must be separated by semicolon, but for the last expression, the
|
||||||
trailing semicolon is optional.
|
trailing semicolon is optional.
|
||||||
|
|
||||||
> queryExprs :: P [QueryExpr]
|
> queryExprs :: P [QueryExpr]
|
||||||
> queryExprs = do
|
> queryExprs =
|
||||||
> ((:[]) <$> queryExpr)
|
> (:[]) <$> queryExpr
|
||||||
> >>= optionSuffix ((symbol ";" *>) . return)
|
> >>= optionSuffix ((symbol ";" *>) . return)
|
||||||
> >>= optionSuffix (\p -> (p++) <$> queryExprs)
|
> >>= optionSuffix (\p -> (p++) <$> queryExprs)
|
||||||
|
|
||||||
|
@ -687,7 +687,7 @@ digits.[digits][e[+-]digits]
|
||||||
[digits].digits[e[+-]digits]
|
[digits].digits[e[+-]digits]
|
||||||
digitse[+-]digits
|
digitse[+-]digits
|
||||||
|
|
||||||
numbers are parsed to strings, not to a numeric type. This is to aoivd
|
numbers are parsed to strings, not to a numeric type. This is to avoid
|
||||||
making a decision on how to represent numbers, the client code can
|
making a decision on how to represent numbers, the client code can
|
||||||
make this choice.
|
make this choice.
|
||||||
|
|
||||||
|
@ -710,7 +710,7 @@ make this choice.
|
||||||
> ,option "" (string "+" <|> string "-")
|
> ,option "" (string "+" <|> string "-")
|
||||||
> ,int]
|
> ,int]
|
||||||
|
|
||||||
lexer for integer literals which appear in some places in sql
|
lexer for integer literals which appear in some places in SQL
|
||||||
|
|
||||||
> integerLiteral :: P Int
|
> integerLiteral :: P Int
|
||||||
> integerLiteral = read <$> many1 digit <* whiteSpace
|
> integerLiteral = read <$> many1 digit <* whiteSpace
|
||||||
|
|
4
README
4
README
|
@ -1 +1,5 @@
|
||||||
A parser for SQL queries in Haskell.
|
A parser for SQL queries in Haskell.
|
||||||
|
|
||||||
|
Homepage: https://github.com/JakeWheat/simple_sql_parser
|
||||||
|
|
||||||
|
Contact: jakewheatmail@gmail.com
|
10
TODO
10
TODO
|
@ -2,8 +2,7 @@
|
||||||
first release:
|
first release:
|
||||||
|
|
||||||
add automated tests to cabal
|
add automated tests to cabal
|
||||||
do code documentation and haddock
|
check the order of exports, imports and functions/cases in the files
|
||||||
check the order of exports, imports and functions/cases in the files
|
|
||||||
fix up the import namespaces/explicit names nicely
|
fix up the import namespaces/explicit names nicely
|
||||||
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
|
||||||
|
@ -14,17 +13,12 @@ Later general tasks:
|
||||||
|
|
||||||
dialect switching
|
dialect switching
|
||||||
|
|
||||||
refactor the join parsing
|
|
||||||
|
|
||||||
left factor parsing code in remaining places
|
left factor parsing code in remaining places
|
||||||
|
|
||||||
reimplement the fixity thing natively
|
reimplement the fixity thing natively
|
||||||
|
|
||||||
fix lexing wrt suffixes 1/2 done
|
|
||||||
|
|
||||||
position annotation?
|
position annotation?
|
||||||
|
|
||||||
|
|
||||||
= sql support
|
= sql support
|
||||||
|
|
||||||
scalar function syntax:
|
scalar function syntax:
|
||||||
|
@ -38,7 +32,7 @@ other missing operators
|
||||||
|
|
||||||
|
|
||||||
review allowed identifier syntax
|
review allowed identifier syntax
|
||||||
add quoted identifers
|
add quoted identifiers
|
||||||
more dots in identifiers
|
more dots in identifiers
|
||||||
order by nulls first/last
|
order by nulls first/last
|
||||||
extend case
|
extend case
|
||||||
|
|
|
@ -2,7 +2,9 @@ name: simple-sql-parser
|
||||||
version: 0.1.0.0
|
version: 0.1.0.0
|
||||||
synopsis: A parser for SQL queries
|
synopsis: A parser for SQL queries
|
||||||
|
|
||||||
description: A parser for SQL queries, using Parsec. Also includes pretty printer. Aims to support most of SQL2003 queries plus other SQL dialects.
|
description: A parser for SQL queries, using Parsec. Also includes
|
||||||
|
pretty printer. Aims to support most of SQL:2003
|
||||||
|
queries plus other SQL dialects.
|
||||||
|
|
||||||
homepage: https://github.com/JakeWheat/simple_sql_parser
|
homepage: https://github.com/JakeWheat/simple_sql_parser
|
||||||
license: BSD3
|
license: BSD3
|
||||||
|
|
Loading…
Reference in a new issue