on master help sign in
Merge pull request #1962 from david-christiansen/issue/1958

Simplify comment parser

commit92e39853b2199745b0a7603ef52f729cfd16a9a2 authorDavid Christiansen <david@davidchristiansen.dk> dateFri 27 Feb 2015, 15:18 (12 years ago) parent54f0cc35f2a3b5
2 files changed+10−11
src/Idris/ParseHelpers.hs+8−10 test/reg050/expected+2−1
src/Idris/ParseHelpers.hs+8−10
@@ -105,30 +105,28 @@ isEol :: Char -> Bool
105105isEol '\n' = True
106106isEol _ = False
107107
108+-- | A parser that succeeds at the end of the line
108109eol :: MonadicParsing m => m ()
109110eol = (satisfy isEol *> pure ()) <|> lookAhead eof <?> "end of line"
110111
111112{- | Consumes a single-line comment
112113
113114@
114− SingleLineComment_t ::= '--' EOL_t
115− | '--' ~DocCommentMarker_t ~EOL_t* EOL_t
116− ;
115+ SingleLineComment_t ::= '--' ~EOL_t* EOL_t ;
117116@
118117 -}
119118singleLineComment :: MonadicParsing m => m ()
120−singleLineComment = try (string "--" *> eol *> pure ())
121− <|> try (string "--" *> many simpleWhiteSpace *>
122− many (satisfy (not . isEol)) *>
123− eol *> pure ())
124− <?> ""
119+singleLineComment = (string "--" *>
120+ many (satisfy (not . isEol)) *>
121+ eol *> pure ())
122+ <?> "single-line comment"
125123
126124{- | Consumes a multi-line comment
127125
128126@
129127 MultiLineComment_t ::=
130128 '{ -- }'
131− | '{ -' ~DocCommentMarker_t InCommentChars_t
129+ | '{ -' InCommentChars_t
132130 ;
133131@
134132
@@ -154,7 +152,7 @@ multiLineComment = try (string "{-" *> (string "-}") *> pure ())
154152 startEnd :: String
155153 startEnd = "{}-"
156154
157−{-| Parses a documentation comment (similar to haddock) given a marker character
155+{-| Parses a documentation comment
158156
159157@
160158 DocComment_t ::= '|||' ~EOL_t* EOL_t
test/reg050/expected+2−1
@@ -23,6 +23,7 @@ When elaborating an application of function Prelude.Monad.>>=:
2323 ambiguous use of a non-associative operator,
2424 ambiguous use of a right-associative operator,
2525 end of input, function argument,
26− matching application expression
26+ matching application expression,
27+ single-line comment
2728doubleBang mmn = do pure !!mmn
2829 ^