mirror of
https://github.com/nikita-volkov/hasql.git
synced 2024-12-29 13:33:03 +03:00
Detect the semicolons with the quasi-quoter
This commit is contained in:
parent
6ce1f5ddb0
commit
e13d21aa38
@ -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 =
|
||||
|
Loading…
Reference in New Issue
Block a user