phaser-0.1.0.0: Incremental multiple pass parser library.

CopyrightJeremy List
LicenseBSD-3
Maintainerquick.dudley@gmail.com
Safe HaskellNone
LanguageHaskell2010

Codec.Phaser.Common

Description

Common functions which do not need to be in Core, mostly for using Phases and Automatons as parsers.

Synopsis

Documentation

data Position Source #

A data type for describing a position in a text file. Constructor arguments are row number and column number.

Constructors

Position !Int !Int 

satisfy :: (i -> Bool) -> Phase p i o i Source #

Consume one input, return it if it matches the predicate, otherwise fail.

match :: Eq i => i -> Phase p i o i Source #

Consume one input, if it's equal to the parameter then return it, otherwise fail.

char :: Char -> Phase p Char o Char Source #

match specialized to Char

iChar :: Char -> Phase p Char o Char Source #

Case insensitive version of char

string :: Eq i => [i] -> Phase p i o [i] Source #

Match a list of input values

iString :: String -> Phase p Char o String Source #

Match a string (case insensitive)

integerDecimal :: Num a => Phase p Char o a Source #

Take some digits and parse a number

decimal :: Fractional a => Phase p Char o a Source #

Parse a number from decimal digits and "."

directHex :: Num a => Phase p Char o a Source #

Take some hexadecimal digits and parse a number from hexadecimal

hex :: Num a => Phase p Char o a Source #

Parse a hexadecimal number prefixed with Ox

integer :: Num a => Phase p Char o a Source #

Parse a number either from decimal digits or from hexadecimal prefixed with "0x"

countChar :: Phase Position i o () Source #

Move the position counter one character to the right

countLine :: Phase Position i o () Source #

Move the position counter to the next line

trackPosition :: Phase Position Char Char () Source #

Count the lines and characters from the input before yielding them again

parse :: Phase Position i o a -> [i] -> Either [(Position, [String])] [a] Source #

Use a Phase as a parser. Note that unlike other parsers the reported position in the input when the parser fails is the position reached when all parsing options are exhausted, not the beginning of the failing token. Since the characters may be counted nondeterministically: if multiple errors are returned the reported error position may be different for each error report.

sepBy :: Phase p i o a -> Phase p i o s -> Phase p i o [a] Source #

sepBy p sep parses zero or more occurrences of p, separated by sep. Returns a list of values returned by p.