StripComments

Plain source file: StripComments.hs (Mar 26)

StripComments is imported by: Main.

module StripComments(stripcomments) where
import HsLexerPass1a(lexerPass1,startPos,nextPos)
import List(mapAccumL)

stripcomments :: String -> String
stripcomments = redo_layout . map snd . lexerPass1

redo_layout ts = concat . snd . mapAccumL place (y0,1) $ ts
  where y0 = fst . fst . head $ ts

place p0 (p,s) = (nextPos p s,space p0 p++s)

space (y0,x0) p@(y,x) =
  if y/=y0 
  then '\n':space (y,1) p -- squeeze blank lines
  else if x0<=x
       then replicate (x-x0) ' '
       else error "Weird layout bug?!"

Index

(HTML for this module was generated on Mar 27. About the conversion tool.)