trifecta-0.38: A modern parser combinator library with convenient diagnostics






class MonadParser m => MonadTokenParser m whereSource


whiteSpace :: m ()Source

Parses any white space. White space consists of zero or more occurrences of a space, a line comment or a block (multi line) comment. Block comments may be nested. How comments are started and ended is defined by this method.

lexeme :: m a -> m aSource

lexeme p first applies parser p and then the whiteSpace parser, returning the value of p. Every lexical token (lexeme) is defined using lexeme, this way every parse starts at a point without white space. Parsers that use lexeme are called lexeme parsers in this document.

The only point where the whiteSpace parser should be called explicitly is the start of the main parser in order to skip any leading white space.

    mainParser  = do { whiteSpace
                     ; ds <- many (lexeme digit)
                     ; eof
                     ; return (sum ds)