peggy-0.2.1: The Parser Generator for Haskell

Portabilityportable
Stabilityexperimental
Maintainertanaka.hideyuki@gmail.com

Text.Peggy.Prim

Contents

Description

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

Synopsis

Parsing functions

parse

Arguments

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

parser

-> SrcPos

input information

-> str

input string

-> Either ParseError a

result

Parsing function

parseString

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

parseFile

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

Constructors

Parser 

Fields

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

Instances

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

The (internal) result type

data Result str a

Constructors

Parsed SrcPos Char str a 
Failed ParseError 

The error type

data ParseError

Constructors

ParseError SrcLoc String 

Instances

Show ParseError 
Error ParseError 
MonadError ParseError (Parser tbl str s) 

The cache type

class MemoTable tbl where

Methods

newTable :: ST s (tbl s)

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 a

Position functions

getPos :: Parser tbl str s SrcPos

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

Combinators

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

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

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

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

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

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

Utiligy

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

defaultDelimiter :: ListLike str Char => Parser tbl str s ()

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