mirror of
https://github.com/mrkkrp/megaparsec.git
synced 2024-12-25 01:07:57 +03:00
parent
ee5f126c14
commit
82994e45d4
@ -3,6 +3,9 @@
|
||||
* Defined `displayException` for `ParseError`, so exceptions are displayed
|
||||
in human-friendly form now. This works with GHC 7.10 and later.
|
||||
|
||||
* Line comments parsed by `skipLineComment` now may end at the end of input
|
||||
and do not necessarily require a newline to be parsed correctly. See #119.
|
||||
|
||||
## Megaparsec 5.0.1
|
||||
|
||||
* Derived `NFData` instances for `Pos`, `InvalidPosException`, `SourcePos`,
|
||||
|
@ -158,7 +158,7 @@ skipLineComment :: (MonadParsec e s m, Token s ~ Char)
|
||||
-> m ()
|
||||
skipLineComment prefix = p >> void (manyTill C.anyChar n)
|
||||
where p = C.string prefix
|
||||
n = lookAhead C.newline
|
||||
n = lookAhead (void C.newline) <|> eof
|
||||
|
||||
-- | @skipBlockComment start end@ skips non-nested block comment starting
|
||||
-- with @start@ and ending with @end@.
|
||||
|
@ -71,6 +71,7 @@ tests = testGroup "Lexer"
|
||||
[ testProperty "space combinator" prop_space
|
||||
, testProperty "symbol combinator" prop_symbol
|
||||
, testProperty "symbol' combinator" prop_symbol'
|
||||
, testCase "case_skipLineCommentEof" case_skipLineCommentEof
|
||||
, testCase "skipBlockCommentNested" case_skipBlockCommentNested
|
||||
, testProperty "indentLevel" prop_indentLevel
|
||||
, testProperty "incorrectIndent" prop_incorrectIndent
|
||||
@ -165,6 +166,12 @@ parseSymbol p' f s' t = checkParser p r s
|
||||
g = takeWhile (not . isSpace) s
|
||||
s = s' ++ maybeToList t
|
||||
|
||||
case_skipLineCommentEof :: Assertion
|
||||
case_skipLineCommentEof = checkCase p r s
|
||||
where p = space (void C.spaceChar) (skipLineComment "//") empty <* eof
|
||||
r = Right ()
|
||||
s = " // this line comment doesn't have a newline at the end "
|
||||
|
||||
case_skipBlockCommentNested :: Assertion
|
||||
case_skipBlockCommentNested = checkCase p r s
|
||||
where p = space (void C.spaceChar) empty
|
||||
|
Loading…
Reference in New Issue
Block a user