[Haskell-cafe] Scheme in Haskell, Parsec Example,
how to add scheme comments
Berlin Brown
berlin.brown at gmail.com
Sun Nov 18 19:32:56 EST 2007
I am sure many of you have looked at the scheme in haskell example that
is on the web by Jonathan Tang. If you are familiar with the code, I
need a little help trying to add scheme style comments:
"; This is my comment"
I added this code here and I think it works (I replaced the name
parseSpaces with his "spaces" function). But, if I start a line with a
comment, it errors out with unbound variable. Anybody have any ideas?
-- Added the ';'
symbol :: Parser Char
symbol = oneOf ";!$%&|*+-/:<=>?@^_~#\n"
--
-- Handle whitespace and comments
parseSpaces :: Parser ()
parseSpaces = (try oneLineComment) <|> whiteSpace <|> return ()
where
whiteSpace = do skipMany1 space
parseSpaces
oneLineComment = do { try (string ";")
; skipMany (satisfy (/= '\n'))
; parseSpaces
}
http://halogen.note.amherst.edu/~jdtang/scheme_in_48/tutorial/overview.html
More information about the Haskell-Cafe
mailing list