Copyright | Jeremy List |
---|---|
License | BSD-3 |
Maintainer | quick.dudley@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
- data Position = Position !Int !Int
- satisfy :: (i -> Bool) -> Phase p i o i
- match :: Eq i => i -> Phase p i o i
- char :: Char -> Phase p Char o Char
- iChar :: Char -> Phase p Char o Char
- string :: Eq i => [i] -> Phase p i o [i]
- iString :: String -> Phase p Char o String
- integerDecimal :: Num a => Phase p Char o a
- decimal :: Fractional a => Phase p Char o a
- directHex :: Num a => Phase p Char o a
- hex :: Num a => Phase p Char o a
- integer :: Num a => Phase p Char o a
- countChar :: Phase Position i o ()
- countLine :: Phase Position i o ()
- trackPosition :: Phase Position Char Char ()
- parse :: Phase Position i o a -> [i] -> Either [(Position, [String])] [a]
- sepBy :: Phase p i o a -> Phase p i o s -> Phase p i o [a]
- munch :: (i -> Bool) -> Phase p i o [i]
- munch1 :: (i -> Bool) -> Phase p i o [i]
- parseFile :: Phase Position Word8 o a -> FilePath -> IO (Either [(Position, [String])] [a])
- latin1 :: Phase p Word8 Char ()
Documentation
A data type for describing a position in a text file. Constructor arguments are row number and column number.
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.
directHex :: Num a => Phase p Char o a Source #
Take some hexadecimal digits and parse a number from hexadecimal
integer :: Num a => Phase p Char o a Source #
Parse a number either from decimal digits or from hexadecimal prefixed with "0x"
trackPosition :: Phase Position Char Char () Source #
Count the lines and characters from the input before yielding them again. If the phase pipeline does not include this or similar: parsing errors will not report the correct position.
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.
munch :: (i -> Bool) -> Phase p i o [i] Source #
Parses the first zero or more values satisfying the predicate. Always succeds, exactly once, having consumed all the characters Hence NOT the same as (many (satisfy p))
munch1 :: (i -> Bool) -> Phase p i o [i] Source #
Parses the first one or more values satisfying the predicate. Always succeds, exactly once, having consumed all the characters Hence NOT the same as (some (satisfy p))