| AnnDocCommentNamed String -- ^ something beginning '-- $'
| AnnDocSection Int String -- ^ a section heading
| AnnDocOptions String -- ^ doc options (prune, ignore-exports, etc)
- | AnnDocOptionsOld String -- ^ doc options declared "-- # ..."-style
| AnnLineComment String -- ^ comment starting by "--"
| AnnBlockComment String -- ^ comment in {- -}
deriving (Eq, Ord, Data, Typeable, Show)
-- space followed by a Haddock comment symbol (docsym) (in which case we'd
-- have a Haddock comment). The rules then munch the rest of the line.
-"-- " ~[$docsym \#] .* { lineCommentToken }
+"-- " ~$docsym .* { lineCommentToken }
"--" [^$symbol \ ] .* { lineCommentToken }
-- Next, match Haddock comments if no -haddock flag
-"-- " [$docsym \#] .* / { ifExtension (not . haddockEnabled) } { lineCommentToken }
+"-- " $docsym .* / { ifExtension (not . haddockEnabled) } { lineCommentToken }
-- Now, when we've matched comments that begin with 2 dashes and continue
-- with a different character, we need to match comments that begin with three
<option_prags> {
"{-#" $whitechar* $pragmachar+ / { known_pragma fileHeaderPrags }
{ dispatch_pragmas fileHeaderPrags }
-
- "-- #" { multiline_doc_comment }
}
<0> {
{ nested_comment lexToken }
}
-<0> {
- "-- #" .* { lineCommentToken }
-}
-
<0,option_prags> {
"{-#" { warnThen Opt_WarnUnrecognisedPragmas (text "Unrecognised pragma")
(nested_comment lexToken) }
| ITdocCommentNamed String -- something beginning '-- $'
| ITdocSection Int String -- a section heading
| ITdocOptions String -- doc options (prune, ignore-exports, etc)
- | ITdocOptionsOld String -- doc options declared "-- # ..."-style
| ITlineComment String -- comment starting by "--"
| ITblockComment String -- comment in {- -}
'^' -> lexDocComment input ITdocCommentPrev False
'$' -> lexDocComment input ITdocCommentNamed True
'*' -> lexDocSection 1 input
- '#' -> lexDocComment input ITdocOptionsOld False
_ -> panic "withLexedDocType: Bad doc type"
where
lexDocSection n input = case alexGetChar' input of
commentToAnnotation (L l (ITdocCommentNamed s)) = L l (AnnDocCommentNamed s)
commentToAnnotation (L l (ITdocSection n s)) = L l (AnnDocSection n s)
commentToAnnotation (L l (ITdocOptions s)) = L l (AnnDocOptions s)
-commentToAnnotation (L l (ITdocOptionsOld s)) = L l (AnnDocOptionsOld s)
commentToAnnotation (L l (ITlineComment s)) = L l (AnnLineComment s)
commentToAnnotation (L l (ITblockComment s)) = L l (AnnBlockComment s)
commentToAnnotation _ = panic "commentToAnnotation"
isDocComment (ITdocCommentNamed _) = True
isDocComment (ITdocSection _ _) = True
isDocComment (ITdocOptions _) = True
-isDocComment (ITdocOptionsOld _) = True
isDocComment _ = False
{- Note [Warnings in code generated by Alex]