From: sof Date: Tue, 29 May 2001 01:07:00 +0000 (+0000) Subject: [project @ 2001-05-29 01:07:00 by sof] X-Git-Tag: Approximately_9120_patches~1851 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=9e4bf486821e06cd3813d3aada6cd8e3acff05a4;p=ghc-hetmet.git [project @ 2001-05-29 01:07:00 by sof] Deal with nested comments (HDirect sources showed up this bug) --- diff --git a/ghc/compiler/main/GetImports.hs b/ghc/compiler/main/GetImports.hs index ecb7766..84d6831 100644 --- a/ghc/compiler/main/GetImports.hs +++ b/ghc/compiler/main/GetImports.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: GetImports.hs,v 1.6 2001/05/01 16:01:06 simonmar Exp $ +-- $Id: GetImports.hs,v 1.7 2001/05/29 01:07:00 sof Exp $ -- -- GHC Driver program -- @@ -82,7 +82,7 @@ clean s keep acc ('\'':cs) = cons acc (squote cs) keep acc ('-':'-':cs) = cons acc (linecomment cs) keep acc ('{':'-':'#':' ':cs) = cons acc (cons "#-{" (keep "" cs)) - keep acc ('{':'-':cs) = cons acc (runcomment cs) -- -} + keep acc ('{':'-':cs) = cons acc (runcomment (0::Int) cs) -- -} keep acc (c:cs) = keep (c:acc) cs cons [] xs = xs @@ -108,6 +108,9 @@ clean s linecomment (c:cs) = linecomment cs -- in a running comment - runcomment [] = [] - runcomment ('-':'}':cs) = keep "" cs - runcomment (c:cs) = runcomment cs + runcomment _ [] = [] + runcomment n ('{':'-':cs) = runcomment (n+1) cs -- catches both nested comments and pragmas. + runcomment n ('-':'}':cs) + | n == 0 = keep "" cs + | otherwise = runcomment (n-1) cs + runcomment n (c:cs) = runcomment n cs