on master help sign in
Merge pull request #1962 from david-christiansen/issue/1958
92e3985David Christiansen
src/Idris/ParseHelpers.hs+8−10
@@ -105,30 +105,28 @@ isEol :: Char -> Bool
105isEol '\n' = True
105isEol '\n' = True
106isEol _ = False
106isEol _ = False
107
107
108+-- | A parser that succeeds at the end of the line
108eol :: MonadicParsing m => m ()
109eol :: MonadicParsing m => m ()
109eol = (satisfy isEol *> pure ()) <|> lookAhead eof <?> "end of line"
110eol = (satisfy isEol *> pure ()) <|> lookAhead eof <?> "end of line"
110
111
111{- | Consumes a single-line comment
112{- | Consumes a single-line comment
112
113
113@
114@
114− SingleLineComment_t ::= '--' EOL_t
115+ SingleLineComment_t ::= '--' ~EOL_t* EOL_t ;
115− | '--' ~DocCommentMarker_t ~EOL_t* EOL_t
116− ;
117@
116@
118 -}
117 -}
119singleLineComment :: MonadicParsing m => m ()
118singleLineComment :: MonadicParsing m => m ()
120−singleLineComment = try (string "--" *> eol *> pure ())
119+singleLineComment = (string "--" *>
121− <|> try (string "--" *> many simpleWhiteSpace *>
122− many (satisfy (not . isEol)) *>
120+ many (satisfy (not . isEol)) *>
123− eol *> pure ())
121+ eol *> pure ())
124− <?> ""
122+ <?> "single-line comment"
125
123
126{- | Consumes a multi-line comment
124{- | Consumes a multi-line comment
127
125
128@
126@
129 MultiLineComment_t ::=
127 MultiLineComment_t ::=
130 '{ -- }'
128 '{ -- }'
131− | '{ -' ~DocCommentMarker_t InCommentChars_t
129+ | '{ -' InCommentChars_t
132 ;
130 ;
133@
131@
134
132
@@ -154,7 +152,7 @@ multiLineComment = try (string "{-" *> (string "-}") *> pure ())
154 startEnd :: String
152 startEnd :: String
155 startEnd = "{}-"
153 startEnd = "{}-"
156
154
157−{-| Parses a documentation comment (similar to haddock) given a marker character
155+{-| Parses a documentation comment
158
156
159@
157@
160 DocComment_t ::= '|||' ~EOL_t* EOL_t
158 DocComment_t ::= '|||' ~EOL_t* EOL_t
test/reg050/expected+2−1
@@ -23,6 +23,7 @@ When elaborating an application of function Prelude.Monad.>>=:
23 ambiguous use of a non-associative operator,
23 ambiguous use of a non-associative operator,
24 ambiguous use of a right-associative operator,
24 ambiguous use of a right-associative operator,
25 end of input, function argument,
25 end of input, function argument,
26− matching application expression
26+ matching application expression,
27+ single-line comment
27doubleBang mmn = do pure !!mmn
28doubleBang mmn = do pure !!mmn
28 ^
29 ^