Annotations-0.2.2: Constructing, analyzing and destructing annotated trees

Safe HaskellSafe
LanguageHaskell98

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 where Source #

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

Minimal complete definition

unparse

Methods

unparse :: s -> String Source #

Unparses a symbol, converting it back to text.

symbolSize :: s -> Int Source #

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

Instances

Symbol s => Symbol [s] Source # 

Methods

unparse :: [s] -> String Source #

symbolSize :: [s] -> Int Source #

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)] Range Source #

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 s Source #

Recognise a symbol matching a predicate.

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

Recognise a specific symbol.

getPos :: Monad m => P s m Range Source #

Yield the current position in the input.