From e97c8fa852931d189ef5ae295aca09fb80a479e0 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Tue, 8 May 2007 12:55:30 +0000 Subject: [PATCH] FIX parsing of Haddock comments (broken by me in the previous patch) --- compiler/parser/Lexer.x | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index 4caca44..b2f08f2 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -699,8 +699,19 @@ notFollowedBy char _ _ _ (AI _ _ buf) notFollowedBySymbol _ _ _ (AI _ _ buf) = nextCharIs buf (`notElem` "!#$%&*+./<=>?@\\^|-~") +-- We must reject doc comments as being ordinary comments everywhere. +-- In some cases the doc comment will be selected as the lexeme due to +-- maximal munch, but not always, because the nested comment rule is +-- valid in all states, but the doc-comment rules are only valid in +-- the non-layout states. isNormalComment bits _ _ (AI _ _ buf) - = nextCharIs buf (/='#') + | haddockEnabled bits = notFollowedByDocOrPragma + | otherwise = nextCharIs buf (/='#') + where + notFollowedByDocOrPragma + = not $ spaceAndP buf (`nextCharIs` (`elem` "|^*$#")) + +spaceAndP buf p = p buf || nextCharIs buf (==' ') && p (snd (nextChar buf)) haddockDisabledAnd p bits _ _ (AI _ _ buf) = if haddockEnabled bits then False else (p buf) -- 1.7.10.4