fixed ‘skipLineComment’ and ‘skipBlockComment’

Multi-character staring/ending sequences should be wrapped with
‘try’. Also, ‘lookAhead’ should not be used in ‘skipBlockComment’.
This commit is contained in:
mrkkrp 2015-09-13 18:51:15 +06:00
parent 26f3039c8b
commit 193d7ade07

View File

@ -140,15 +140,17 @@ indentGuard spc p = do
-- parser or picked up manually.
skipLineComment :: Stream s m Char => String -> ParsecT s u m ()
skipLineComment prefix = C.string prefix >> void (manyTill C.anyChar n)
where n = lookAhead C.newline
skipLineComment prefix = p >> void (manyTill C.anyChar n)
where p = try $ C.string prefix
n = lookAhead C.newline
-- | @skipBlockComment start end@ skips non-nested block comment starting
-- with @start@ and ending with @end@.
skipBlockComment :: Stream s m Char => String -> String -> ParsecT s u m ()
skipBlockComment start end = C.string start >> void (manyTill C.anyChar n)
where n = lookAhead . try $ C.string end
skipBlockComment start end = p >> void (manyTill C.anyChar n)
where p = try $ C.string start
n = try $ C.string end
-- Character and string literals