boomerang-1.0.0: Library for invertible parsing and printing

Text.Boomerang.Strings

Contents

Description

a PrinterParser library for working with '[String]'

Synopsis

Types

Combinators

alpha :: PrinterParser StringsError [String] r (Char :- r)Source

matches alphabetic Unicode characters (lower-case, upper-case and title-case letters, plus letters of caseless scripts and modifiers letters). (Uses isAlpha)

char :: Char -> PrinterParser StringsError [String] r (Char :- r)Source

matches the specified character

digit :: PrinterParser StringsError [String] r (Char :- r)Source

ascii digits '0'..'9'

lit :: String -> PrinterParser StringsError [String] r rSource

a constant string

satisfy :: (Char -> Bool) -> PrinterParser StringsError [String] r (Char :- r)Source

statisfy a Char predicate

satisfyStr :: (String -> Bool) -> PrinterParser StringsError [String] r (String :- r)Source

satisfy a String predicate.

Note: must match the entire remainder of the String in this segment

space :: PrinterParser StringsError [String] r (Char :- r)Source

matches white-space characters in the Latin-1 range. (Uses isSpace)

Running the PrinterParser

isComplete :: [String] -> BoolSource

Predicate to test if we have parsed all the strings. Typically used as argument to parse1

see also: parseStrings

parseStrings :: PrinterParser StringsError [String] () (r :- ()) -> [String] -> Either StringsError rSource

run the parser

Returns the first complete parse or a parse error.

 parseStrings (rUnit . lit "foo") ["foo"]

unparseStrings :: PrinterParser e [String] () (r :- ()) -> r -> Maybe [String]Source

run the printer

 unparseStrings (rUnit . lit "foo") ()