ddc-core-0.4.3.1: Disciplined Disciple Compiler core language and type checker.

Safe HaskellSafe
LanguageHaskell98

DDC.Control.Parser

Contents

Description

Parser utilities.

Synopsis

Documentation

type Parser k a = Eq k => ParsecT [Located k] (ParserState k) Identity a Source #

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 

data SourcePos Source #

A position in a source file.

If there is no file path then we assume that the input has been read from an interactive session and display ''<interactive>'' when pretty printing.

runTokenParser Source #

Arguments

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

Show a token.

-> String

File name for error messages.

-> Parser k a

Parser to run.

-> [Located k]

Tokens to parse.

-> Either ParseError a 

Run a generic parser, making sure all input is consumed.

pTokMaybe :: (k -> Maybe a) -> Parser k a Source #

Accept a token if the function returns Just.

pTokMaybeSP :: (k -> Maybe a) -> Parser k (a, SourcePos) Source #

Accept a token if the function return Just, also returning the source position of that token.

pTokAs :: k -> t -> Parser k t Source #

Accept a token and return the given value.

pTokAsSP :: k -> t -> Parser k (t, SourcePos) Source #

Accept a token and return the given value, along with the source position of the token.

pTok :: k -> Parser k () Source #

Accept the given token.

pTokSP :: k -> Parser k SourcePos Source #

Accept the given token, returning its source position.

Orphan instances

Pretty ParseError Source # 

Associated Types

data PrettyMode ParseError :: * Source #

Methods

pprDefaultMode :: PrettyMode ParseError Source #

ppr :: ParseError -> Doc Source #

pprPrec :: Int -> ParseError -> Doc Source #

pprModePrec :: PrettyMode ParseError -> Int -> ParseError -> Doc Source #

Pretty Message Source # 

Associated Types

data PrettyMode Message :: * Source #

Methods

pprDefaultMode :: PrettyMode Message Source #

ppr :: Message -> Doc Source #

pprPrec :: Int -> Message -> Doc Source #

pprModePrec :: PrettyMode Message -> Int -> Message -> Doc Source #