work on the semicolon handling
This commit is contained in:
parent
cd7a15c193
commit
3f08adb4c5
3 changed files with 22 additions and 6 deletions
Language/SQL/SimpleSQL
|
@ -612,7 +612,7 @@ wrapper for query expr which ignores optional trailing semicolon.
|
|||
|
||||
> topLevelQueryExpr :: P QueryExpr
|
||||
> topLevelQueryExpr =
|
||||
> queryExpr <* (choice [try $ symbol_ ";", return()])
|
||||
> queryExpr >>= optionSuffix ((symbol ";" *>) . return)
|
||||
|
||||
wrapper to parse a series of query exprs from a single source. They
|
||||
must be separated by semicolon, but for the last expression, the
|
||||
|
@ -620,11 +620,9 @@ trailing semicolon is optional.
|
|||
|
||||
> queryExprs :: P [QueryExpr]
|
||||
> queryExprs = do
|
||||
> qe <- queryExpr
|
||||
> choice [[qe] <$ eof
|
||||
> ,symbol_ ";" *>
|
||||
> choice [[qe] <$ eof
|
||||
> ,(:) qe <$> queryExprs]]
|
||||
> ((:[]) <$> queryExpr)
|
||||
> >>= optionSuffix ((symbol ";" *>) . return)
|
||||
> >>= optionSuffix (\p -> (p++) <$> queryExprs)
|
||||
|
||||
------------------------------------------------
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ back into SQL source text. It attempts to format the output nicely.
|
|||
> module Language.SQL.SimpleSQL.Pretty
|
||||
> (prettyQueryExpr
|
||||
> ,prettyScalarExpr
|
||||
> ,prettyQueryExprs
|
||||
> ) where
|
||||
|
||||
> import Language.SQL.SimpleSQL.Syntax
|
||||
|
@ -17,6 +18,8 @@ back into SQL source text. It attempts to format the output nicely.
|
|||
> prettyScalarExpr :: ScalarExpr -> String
|
||||
> prettyScalarExpr = render . scalarExpr
|
||||
|
||||
> prettyQueryExprs :: [QueryExpr] -> String
|
||||
> prettyQueryExprs = render . vcat . map ((<> text ";") . queryExpr)
|
||||
|
||||
= scalar expressions
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue