Annotations-0.2: Constructing, analyzing and destructing annotated trees

Safe HaskellSafe-Infered

Annotations.BoundsParser

Contents

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.

Synopsis

Symbols

class Symbol s whereSource

Symbols form input for parsers. Minimal complete definition: unparse.

Methods

unparse :: s -> StringSource

Unparses a symbol, converting it back to text.

symbolSize :: s -> IntSource

Yields the size of a symbol. Default implementation is length . unparse.

Instances

Symbol s => Symbol [s] 

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.

satisfy :: (Monad m, Symbol s) => (s -> Bool) -> P s m sSource

Recognise a symbol matching a predicate.

pToken :: (Monad m, Symbol s, Eq s) => s -> P s m sSource

Recognise a specific symbol.

getPos :: Monad m => P s m RangeSource

Yield the current position in the input.