On Sun, 2007-11-18 at 19:37 -0500, Berlin Brown wrote: > On Nov 18, 2007 7:32 PM, Berlin Brown <[EMAIL PROTECTED]> wrote: > > 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"
The preferred way to do that is to use a token helper function: token :: P a -> P a token p = do r <- p whiteSpace return r -- or, if you add a Control.Applicative instance for your -- parser type, this is just: token p = p <* whiteSpace Then you handle comments as whitespace: whiteSpace :: P () whiteSpace = skipMany $ spaces <|> (char ';' >> skipMany (satisfy (/='\n'))) Then you just use that like this: symbol :: P String symbol = token $ many1 $ satisfy $ not . (`elem` "()[]; ") See also Parsec's TokenParser. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe