On Nov 18, 2007 8:01 PM, Thomas Schilling <[EMAIL PROTECTED]> wrote: > 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. > >
token :: Parser -> Parser String token p = do r <- p whiteSpace return $ String r I know I am being lazy, but what am I missing in your pseudo code: I tried playing with your example but kept getting these errors: Parsec3.hs:23:13: The last statement in a 'do' construct must be an expression at the token line. -- Berlin Brown http://botspiritcompany.com/botlist/spring/help/about.html _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe