ddc-base-0.2.1.2: Disciple Core language common utilities.

Safe HaskellNone

DDC.Base.Parser

Description

Parser utilities.

Synopsis

Documentation

type Parser k a = Eq k => ParsecT [Token k] (ParserState k) Identity aSource

A generic parser, parameterised over token and return types.

data ParserState k Source

A parser state that keeps track of the name of the source file.

Constructors

ParseState 

runTokenParserSource

Arguments

:: Eq k 
=> (k -> String)

Show a token.

-> String

File name for error messages.

-> Parser k a

Parser to run.

-> [Token k]

Tokens to parse.

-> Either ParseError a 

Run a generic parser.

pTokMaybe :: (k -> Maybe a) -> Parser k aSource

Accept a token if the function returns Just.

pTokAs :: Eq k => k -> t -> Parser k tSource

Accept a token and return the given value.

pTok :: Eq k => k -> Parser k ()Source

Accept the given token.