wumpus-basic-0.24.0: Basic objects and system code built on Wumpus-Core.

PortabilityGHC
Stabilityhighly unstable
MaintainerStephen Tetley <stephen.tetley@gmail.com>
Safe HaskellSafe-Infered

Wumpus.Basic.Utils.TokenParsers

Description

Generally you should expect to import this module qualified and define versions to consume trailing white-space.

 lexDef   :: P.LexemeParser
 lexDef   = P.commentLineLexemeParser "Comment" [' ', '\t']

 lexeme   :: CharParser a -> CharParser a
 lexeme   = P.lexeme lexDef

 integer  :: CharParser Int
 integer  = lexeme P.integer

Synopsis

Documentation

data LexemeParser Source

Opaque type representing a parser that consumes arbitrary space.

Unlike Parsec's lexeme parser, this can be customized so that e.g. newlines are not consumed as white space.

spaceLexemeParser :: LexemeParserSource

Build a lexeme parser that handles space.

Space is zero or more elements matching the isSpace predicate from Data.Char.

spaceCharLexemeParser :: [Char] -> LexemeParserSource

Build a lexeme parser that handles arbitrary space.

space is parametric, for instance this can manufacture a lexeme parser that consumes space and tab chars but not newline.

commentLexemeParser :: String -> (String, String) -> [Char] -> LexemeParserSource

Build a lexeme parser that handles start-and-end delimited comments and arbitrary space.

commentLineLexemeParser :: String -> [Char] -> LexemeParserSource

Build a lexeme parser that handles line spanning comments an arbitrary space.

commentMultiLexemeParser :: String -> String -> [Char] -> LexemeParserSource

Build a lexeme parser that handles start-and-end delimited comments, line comments and arbitrary space.

lexeme :: LexemeParser -> CharParser a -> CharParser aSource

Wrap a CharParser with a lexeme parser, the CharParser will consume trailing space according to the strategy of the LexemeParser.