Annotations.BoundsParser
Description
A Parsec parser type that parses Symbols and keeps track of the
position within the input stream. Unlike Parsec's default position
tracking, this parser keeps track of the range of whitespace between two
tokens.
- class Symbol s where
- unparse :: s -> String
- symbolSize :: s -> Int
- collapse :: Symbol s => (s -> Bool) -> [s] -> [(s, Bounds)]
- type P s = ParsecT [(s, Bounds)] Range
- satisfy :: (Monad m, Symbol s) => (s -> Bool) -> P s m s
- pToken :: (Monad m, Symbol s, Eq s) => s -> P s m s
- getPos :: Monad m => P s m Range
Symbols
Symbols form input for parsers. Minimal complete definition: unparse.
Methods
Unparses a symbol, converting it back to text.
symbolSize :: s -> IntSource
Yields the size of a symbol. Default implementation is length . unparse.
collapse :: Symbol s => (s -> Bool) -> [s] -> [(s, Bounds)]Source
Given a predicate that tells what tokens to discard, keeps only the meaningful tokens and couples them with position information.
Parsing
type P s = ParsecT [(s, Bounds)] RangeSource
A parser that works on symbols coupled with token information. The state maintains the current position in the stream. This position is the range of whitespace between two tokens.