summaryrefslogtreecommitdiff
path: root/ghc/compiler/parser/Lexer.x
diff options
context:
space:
mode:
authorsimonmar <unknown>2004-02-24 10:34:21 +0000
committersimonmar <unknown>2004-02-24 10:34:21 +0000
commit42be1de4d0cc2c72945a1948a6489376cc24e692 (patch)
treeb08a6aa3fe622b9277ee7415a6d0de0156dce3d6 /ghc/compiler/parser/Lexer.x
parent0689f025fa6838d20aa417d81a6e93938fb13971 (diff)
downloadhaskell-42be1de4d0cc2c72945a1948a6489376cc24e692.tar.gz
[project @ 2004-02-24 10:34:21 by simonmar]
Fix line-comments. The problem was that eg. ---> at the beginning of a line was matched by the line-comment rule, because the varsym rule isn't valid at this point (we're in the bol state). Fix is to split the line-comment regex into two: "--"\-* [^$symbol] .* ; "--"\-* / { atEOL } ; so a sequence of dashes on its own is only treated as a comment if we're at the end of the line (or file). Otherwise the dashes must be followed by a non-symbol character.
Diffstat (limited to 'ghc/compiler/parser/Lexer.x')
-rw-r--r--ghc/compiler/parser/Lexer.x5
1 files changed, 4 insertions, 1 deletions
diff --git a/ghc/compiler/parser/Lexer.x b/ghc/compiler/parser/Lexer.x
index e83bf944b6..2d01a18967 100644
--- a/ghc/compiler/parser/Lexer.x
+++ b/ghc/compiler/parser/Lexer.x
@@ -108,7 +108,8 @@ $white_no_nl+ ;
-- have to exclude those.
-- The regex says: "munch all the characters after the dashes, as long as
-- the first one is not a symbol".
-"--"\-* ([^$symbol] .*)? ;
+"--"\-* [^$symbol] .* ;
+"--"\-* / { atEOL } ;
-- 'bol' state: beginning of a line. Slurp up all the whitespace (including
-- blank lines) until we find a non-whitespace character, then do layout
@@ -582,6 +583,8 @@ notFollowedBy char _ _ _ (_,buf) = atEnd buf || currentChar buf /= char
notFollowedBySymbol _ _ _ (_,buf)
= atEnd buf || currentChar buf `notElem` "!#$%&*+./<=>?@\\^|-~"
+atEOL _ _ _ (_,buf) = atEnd buf || currentChar buf == '\n'
+
ifExtension pred bits _ _ _ = pred bits
{-