1
Fork 0

few small typos, etc.

This commit is contained in:
Jake Wheat 2013-12-14 17:09:45 +02:00
parent b6633bf73c
commit 3fa7086a48
5 changed files with 23 additions and 23 deletions

View file

@ -88,13 +88,13 @@ the fixity code.
> HSE.App (var ('a':nm))
> $ HSE.List [str $ show (d,map snd od)
> ,HSE.List $ map toHaskell es
> ,HSE.List $ map toHaskell $ map fst od]
> ,HSE.List $ map (toHaskell . fst) od]
> WindowApp nm es pb od ->
> HSE.App (var ('w':nm))
> $ HSE.List [str $ show (map snd od)
> ,HSE.List $ map toHaskell es
> ,HSE.List $ map toHaskell pb
> ,HSE.List $ map toHaskell $ map fst od]
> ,HSE.List $ map (toHaskell . fst) od]
> PrefixOp nm e0 ->
> HSE.App (HSE.Var $ sym nm) (toHaskell e0)
> PostfixOp nm e0 ->

View file

@ -16,26 +16,26 @@
> import Language.SQL.SimpleSQL.Syntax
> import Language.SQL.SimpleSQL.Fixity
The public api functions.
The public API functions.
> -- | Parses a query expr, trailing semicolon optional.
> parseQueryExpr :: FilePath -- ^ filename 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
> parseQueryExpr = wrapParse topLevelQueryExpr
> -- | Parses a list of query exprs, with semi colons between them. The final semicolon is optional.
> parseQueryExprs :: FilePath -- ^ filename 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]
> parseQueryExprs = wrapParse queryExprs
> -- | Parses a scalar expression.
> parseScalarExpr :: FilePath -- ^ filename 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
> 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
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.
@ -362,7 +362,7 @@ The parsers:
> keywords_ = try . mapM_ keyword_
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 bExpr e0 =
@ -381,7 +381,7 @@ associativity. This is fixed with a separate pass over the ast.
> sqlFixities = highPrec ++ defaultPrec ++ lowPrec
> where
> allOps = binOpSymbolNames ++ binOpKeywordNames
> ++ (map unwords binOpMultiKeywordNames)
> ++ map unwords binOpMultiKeywordNames
> ++ prefixUnOpKeywordNames ++ prefixUnOpSymbolNames
> ++ postfixOpKeywords
> -- these are the ops with the highest precedence in order
@ -498,7 +498,7 @@ tref
> $ commaSep1 identifierString
> in option j (TRAlias j <$> try tableAlias <*> try columnAliases)
> joinTrefSuffix t = (do
> nat <- option False $ try (True <$ (try $ keyword_ "natural"))
> nat <- option False $ try (True <$ try (keyword_ "natural"))
> TRJoin t <$> joinType
> <*> nonJoinTref
> <*> optionMaybe (joinCondition nat))
@ -610,8 +610,8 @@ must be separated by semicolon, but for the last expression, the
trailing semicolon is optional.
> queryExprs :: P [QueryExpr]
> queryExprs = do
> ((:[]) <$> queryExpr)
> queryExprs =
> (:[]) <$> queryExpr
> >>= optionSuffix ((symbol ";" *>) . return)
> >>= optionSuffix (\p -> (p++) <$> queryExprs)
@ -687,7 +687,7 @@ digits.[digits][e[+-]digits]
[digits].digits[e[+-]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
make this choice.
@ -710,7 +710,7 @@ make this choice.
> ,option "" (string "+" <|> string "-")
> ,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 = read <$> many1 digit <* whiteSpace

4
README
View file

@ -1 +1,5 @@
A parser for SQL queries in Haskell.
Homepage: https://github.com/JakeWheat/simple_sql_parser
Contact: jakewheatmail@gmail.com

8
TODO
View file

@ -2,7 +2,6 @@
first release:
add automated tests to cabal
do code documentation and haddock
check the order of exports, imports and functions/cases in the files
fix up the import namespaces/explicit names nicely
do some tests for parse errors?
@ -14,17 +13,12 @@ Later general tasks:
dialect switching
refactor the join parsing
left factor parsing code in remaining places
reimplement the fixity thing natively
fix lexing wrt suffixes 1/2 done
position annotation?
= sql support
scalar function syntax:
@ -38,7 +32,7 @@ other missing operators
review allowed identifier syntax
add quoted identifers
add quoted identifiers
more dots in identifiers
order by nulls first/last
extend case

View file

@ -2,7 +2,9 @@ name: simple-sql-parser
version: 0.1.0.0
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
license: BSD3