attempt to improve some parse errors, change some imports to be explicit
This commit is contained in:
parent
9cadbee355
commit
a3d1ba7e5c
|
@ -14,7 +14,7 @@ module Language.SQL.SimpleSQL.Dialect
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import Data.Data
|
import Data.Data (Data,Typeable)
|
||||||
|
|
||||||
-- | Used to set the dialect used for parsing and pretty printing,
|
-- | Used to set the dialect used for parsing and pretty printing,
|
||||||
-- very unfinished at the moment.
|
-- very unfinished at the moment.
|
||||||
|
|
|
@ -392,7 +392,7 @@ names = reverse <$> (((:[]) <$> name) <??*> anotherName)
|
||||||
-- this will change when this is left factored
|
-- this will change when this is left factored
|
||||||
where
|
where
|
||||||
anotherName :: Parser ([Name] -> [Name])
|
anotherName :: Parser ([Name] -> [Name])
|
||||||
anotherName = try ((:) <$> (symbol "." *> name))
|
anotherName = try ((:) <$> ((symbol "." *> name) <?> ""))
|
||||||
|
|
||||||
{-
|
{-
|
||||||
= Type Names
|
= Type Names
|
||||||
|
@ -1369,7 +1369,7 @@ from = keyword_ "from" *> commaSep1 tref
|
||||||
where
|
where
|
||||||
-- TODO: use P (a->) for the join tref suffix
|
-- TODO: use P (a->) for the join tref suffix
|
||||||
-- chainl or buildexpressionparser
|
-- chainl or buildexpressionparser
|
||||||
tref = nonJoinTref >>= optionSuffix joinTrefSuffix
|
tref = (nonJoinTref <?> "table ref") >>= optionSuffix (joinTrefSuffix)
|
||||||
nonJoinTref = choice
|
nonJoinTref = choice
|
||||||
[parens $ choice
|
[parens $ choice
|
||||||
[TRQueryExpr <$> queryExpr
|
[TRQueryExpr <$> queryExpr
|
||||||
|
@ -1387,11 +1387,11 @@ from = keyword_ "from" *> commaSep1 tref
|
||||||
] <??> aliasSuffix
|
] <??> aliasSuffix
|
||||||
aliasSuffix = fromAlias <$$> TRAlias
|
aliasSuffix = fromAlias <$$> TRAlias
|
||||||
joinTrefSuffix t =
|
joinTrefSuffix t =
|
||||||
(TRJoin t <$> option False (True <$ keyword_ "natural")
|
((TRJoin t <$> option False (True <$ keyword_ "natural")
|
||||||
<*> joinType
|
<*> joinType
|
||||||
<*> nonJoinTref
|
<*> nonJoinTref
|
||||||
<*> optional joinCondition)
|
<*> optional joinCondition)
|
||||||
>>= optionSuffix joinTrefSuffix
|
>>= optionSuffix joinTrefSuffix) <?> ""
|
||||||
|
|
||||||
{-
|
{-
|
||||||
TODO: factor the join stuff to produce better error messages (and make
|
TODO: factor the join stuff to produce better error messages (and make
|
||||||
|
@ -1520,7 +1520,7 @@ queryExpr = E.makeExprParser qeterm qeOpTable
|
||||||
mkSelect
|
mkSelect
|
||||||
<$> option SQDefault duplicates
|
<$> option SQDefault duplicates
|
||||||
<*> selectList
|
<*> selectList
|
||||||
<*> optional tableExpression
|
<*> (optional tableExpression) <?> "table expression"
|
||||||
mkSelect d sl Nothing =
|
mkSelect d sl Nothing =
|
||||||
makeSelect{qeSetQuantifier = d, qeSelectList = sl}
|
makeSelect{qeSetQuantifier = d, qeSelectList = sl}
|
||||||
mkSelect d sl (Just (TableExpression f w g h od ofs fe)) =
|
mkSelect d sl (Just (TableExpression f w g h od ofs fe)) =
|
||||||
|
@ -1534,10 +1534,10 @@ queryExpr = E.makeExprParser qeterm qeOpTable
|
||||||
,[E.InfixL $ setOp Except "except"
|
,[E.InfixL $ setOp Except "except"
|
||||||
,E.InfixL $ setOp Union "union"]]
|
,E.InfixL $ setOp Union "union"]]
|
||||||
setOp :: SetOperatorName -> Text -> Parser (QueryExpr -> QueryExpr -> QueryExpr)
|
setOp :: SetOperatorName -> Text -> Parser (QueryExpr -> QueryExpr -> QueryExpr)
|
||||||
setOp ctor opName = cq
|
setOp ctor opName = (cq
|
||||||
<$> (ctor <$ keyword_ opName)
|
<$> (ctor <$ keyword_ opName)
|
||||||
<*> option SQDefault duplicates
|
<*> option SQDefault duplicates
|
||||||
<*> corr
|
<*> corr) <?> ""
|
||||||
cq o d c q0 q1 = QueryExprSetOp q0 o d c q1
|
cq o d c q0 q1 = QueryExprSetOp q0 o d c q1
|
||||||
corr = option Respectively (Corresponding <$ keyword_ "corresponding")
|
corr = option Respectively (Corresponding <$ keyword_ "corresponding")
|
||||||
|
|
||||||
|
@ -1559,12 +1559,12 @@ data TableExpression
|
||||||
,_teFetchFirst :: Maybe ScalarExpr}
|
,_teFetchFirst :: Maybe ScalarExpr}
|
||||||
|
|
||||||
tableExpression :: Parser TableExpression
|
tableExpression :: Parser TableExpression
|
||||||
tableExpression = mkTe <$> from
|
tableExpression = mkTe <$> (from <?> "from clause")
|
||||||
<*> optional whereClause
|
<*> (optional whereClause <?> "where clause")
|
||||||
<*> option [] groupByClause
|
<*> (option [] groupByClause <?> "group by clause")
|
||||||
<*> optional having
|
<*> (optional having <?> "having clause")
|
||||||
<*> option [] orderBy
|
<*> (option [] orderBy <?> "order by clause")
|
||||||
<*> offsetFetch
|
<*> (offsetFetch <?> "")
|
||||||
where
|
where
|
||||||
mkTe f w g h od (ofs,fe) =
|
mkTe f w g h od (ofs,fe) =
|
||||||
TableExpression f w g h od ofs fe
|
TableExpression f w g h od ofs fe
|
||||||
|
@ -2198,10 +2198,10 @@ closeBracket = singleCharSymbol ']'
|
||||||
|
|
||||||
|
|
||||||
comma :: Parser Char
|
comma :: Parser Char
|
||||||
comma = singleCharSymbol ','
|
comma = singleCharSymbol ',' <?> ""
|
||||||
|
|
||||||
semi :: Parser Char
|
semi :: Parser Char
|
||||||
semi = singleCharSymbol ';'
|
semi = singleCharSymbol ';' <?> ""
|
||||||
|
|
||||||
-- = helper functions
|
-- = helper functions
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ module Language.SQL.SimpleSQL.Syntax
|
||||||
|
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
|
|
||||||
import Data.Data
|
import Data.Data (Data, Typeable)
|
||||||
|
|
||||||
-- | Represents a value expression. This is used for the expressions
|
-- | Represents a value expression. This is used for the expressions
|
||||||
-- in select lists. It is also used for expressions in where, group
|
-- in select lists. It is also used for expressions in where, group
|
||||||
|
|
Loading…
Reference in a new issue