From 3fa7086a48cb0238b9475ca9201d0618472328bc Mon Sep 17 00:00:00 2001 From: Jake Wheat Date: Sat, 14 Dec 2013 17:09:45 +0200 Subject: [PATCH] few small typos, etc. --- Language/SQL/SimpleSQL/Fixity.lhs | 4 ++-- Language/SQL/SimpleSQL/Parser.lhs | 24 ++++++++++++------------ README | 4 ++++ TODO | 10 ++-------- simple-sql-parser.cabal | 4 +++- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Language/SQL/SimpleSQL/Fixity.lhs b/Language/SQL/SimpleSQL/Fixity.lhs index 526f42b..67521a5 100644 --- a/Language/SQL/SimpleSQL/Fixity.lhs +++ b/Language/SQL/SimpleSQL/Fixity.lhs @@ -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 -> diff --git a/Language/SQL/SimpleSQL/Parser.lhs b/Language/SQL/SimpleSQL/Parser.lhs index fa7785d..da120cf 100644 --- a/Language/SQL/SimpleSQL/Parser.lhs +++ b/Language/SQL/SimpleSQL/Parser.lhs @@ -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 diff --git a/README b/README index 0c60a9e..53efe23 100644 --- a/README +++ b/README @@ -1 +1,5 @@ A parser for SQL queries in Haskell. + +Homepage: https://github.com/JakeWheat/simple_sql_parser + +Contact: jakewheatmail@gmail.com \ No newline at end of file diff --git a/TODO b/TODO index e1b75cd..f959723 100644 --- a/TODO +++ b/TODO @@ -2,8 +2,7 @@ first release: 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 do some tests for parse errors? website with haddock and table of parsing tests @@ -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 diff --git a/simple-sql-parser.cabal b/simple-sql-parser.cabal index e01eb00..b234247 100644 --- a/simple-sql-parser.cabal +++ b/simple-sql-parser.cabal @@ -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