From e13d21aa38e1b2a579fb98b4381f1bfaf4f97ab3 Mon Sep 17 00:00:00 2001 From: Nikita Volkov Date: Sun, 30 Nov 2014 00:15:34 +0300 Subject: [PATCH] Detect the semicolons with the quasi-quoter --- library/Hasql/QParser.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/library/Hasql/QParser.hs b/library/Hasql/QParser.hs index 10e862c..a0cd3e4 100644 --- a/library/Hasql/QParser.hs +++ b/library/Hasql/QParser.hs @@ -12,16 +12,16 @@ type Result = parse :: Text -> Either String Result parse = - parseOnly countPlaceholders + parseOnly $ flip execStateT 0 $ + statement *> + (lift endOfInput <|> + (void (lift (char ';')) <* fail "A semicolon detected. Only single statements are allowed")) where - countPlaceholders = - count <|> pure 0 - where - count = - do - many $ void stringLit <|> void (notChar '?') - char '?' - fmap succ countPlaceholders + statement = + skipMany1 $ + void (lift stringLit) <|> + void (lift (char '?') <* modify succ) <|> + void (lift (notChar ';')) stringLit :: Parser Text stringLit =