peggy-0.3.2: The Parser Generator for Haskell

Portabilityportable
Stabilityexperimental
Maintainertanaka.hideyuki@gmail.com
Safe HaskellNone

Text.Peggy.Prim

Contents

Description

The monadic parser type and combinators to construct packrat parsers for code generator.

Synopsis

Parsing functions

parseSource

Arguments

:: MemoTable tbl 
=> (forall s. Parser tbl str s a)

parser

-> SrcPos

input information

-> str

input string

-> Either ParseError a

result

Parsing function

parseStringSource

Arguments

:: MemoTable tbl 
=> (forall s. Parser tbl str s a)

parser

-> String

input name

-> str

input string

-> Either ParseError a

result

Parsing function with only input name

parseFileSource

Arguments

:: MemoTable tbl 
=> (forall s. Parser tbl String s a)

parser

-> FilePath

input filename

-> IO (Either ParseError a)

result

Parse from file

The parser type

newtype Parser tbl str s a Source

Constructors

Parser 

Fields

unParser :: tbl s -> SrcPos -> Char -> str -> ST s (Result str a)
 

Instances

Monad (Parser tbl str s) => MonadError ParseError (Parser tbl str s) 
Monad (Parser tbl str s) 
Functor (Parser tbl str s) 
Functor (Parser tbl str s) => Applicative (Parser tbl str s) 
Applicative (Parser tbl str s) => Alternative (Parser tbl str s) 

The (internal) result type

data Result str a Source

Constructors

Parsed SrcPos Char str a 
Failed ParseError 

The error type

data ParseError Source

Constructors

ParseError SrcLoc String 

Instances

The cache type

class MemoTable tbl whereSource

Methods

newTable :: ST s (tbl s)Source

Instances

MemoTable (MemoTable_0 str_4) 

Memoising combinator

memo :: (tbl s -> HashTable s Int (Result str a)) -> Parser tbl str s a -> Parser tbl str s aSource

Position functions

setPos :: SrcPos -> Parser tbl str s ()Source

Combinators

anyChar :: ListLike str Char => Parser tbl str s CharSource

satisfy :: ListLike str Char => (Char -> Bool) -> Parser tbl str s CharSource

char :: ListLike str Char => Char -> Parser tbl str s CharSource

string :: ListLike str Char => String -> Parser tbl str s StringSource

expect :: ListLike str Char => Parser tbl str s a -> Parser tbl str s ()Source

unexpect :: ListLike str Char => Parser tbl str s a -> Parser tbl str s ()Source

Utiligy

space :: ListLike str Char => Parser tbl str s ()Source

token :: ListLike str Char => Parser tbl str s () -> Parser tbl str s () -> Parser tbl str s a -> Parser tbl str s aSource