invertible-syntax-poly-0.1.0.1: Extends invertible-syntax library capable to use parameterized token type.

Copyright2010-11 University of Marburg, 2012 Kei Hibino
LicenseBSD3
Maintainerex8k.hibino@gmail.com
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell98

Text.Syntax.Poly.Combinators

Contents

Description

This module contains combinators for classes defined in Text.Syntax.Poly.Classes.

Synopsis

Lexemes

this :: (Syntax tok delta, Eq tok) => tok -> delta () Source

The this combinator parses/prints a fixed token

list :: (Syntax tok delta, Eq tok) => [tok] -> delta () Source

The list combinator parses/prints a fixed token list and consumes/produces a unit value.

Repetition

none :: AbstractSyntax delta => delta [alpha] Source

none parses/prints empty tokens stream consume/produces a empty list.

many :: AbstractSyntax delta => delta alpha -> delta [alpha] Source

The many combinator is used to repeat syntax. many p repeats the passed syntax p zero or more than zero times.

some :: AbstractSyntax delta => delta alpha -> delta [alpha] Source

The some combinator is used to repeat syntax. some p repeats the passed syntax p more than zero times.

replicate :: AbstractSyntax delta => Int -> delta alpha -> delta [alpha] Source

The replicate combinator is used to repeat syntax. replicate n p repeats the passwd syntax p n times.

sepBy :: AbstractSyntax delta => delta alpha -> delta () -> delta [alpha] Source

The sepBy combinator separates syntax into delimited list. sepBy p d is p list syntax delimited by d syntax.

sepBy1 :: AbstractSyntax delta => delta alpha -> delta () -> delta [alpha] Source

The sepBy1 combinator separates syntax into delimited non-empty list. sepBy p d is p list syntax delimited by d syntax.

chainl1 :: AbstractSyntax delta => delta alpha -> delta beta -> Iso (alpha, (beta, alpha)) alpha -> delta alpha Source

The chainl1 combinator is used to parse a left-associative chain of infix operators.

count :: (Eq beta, Enum beta, AbstractSyntax delta) => delta () -> delta beta Source

The count combinator counts fixed syntax.

Skipping

skipMany :: AbstractSyntax delta => delta alpha -> delta () Source

The skipMany p parse the passed syntax p zero or more than zero times, and print nothing.

skipSome :: AbstractSyntax delta => delta alpha -> delta alpha Source

The skipSome v p parse the passed syntax p more than zero times, and print p.

Sequencing

(*>) :: AbstractSyntax delta => delta () -> delta alpha -> delta alpha infixl 7 Source

This variant of <*> ignores its left result. In contrast to its counterpart derived from the Applicative class, the ignored parts have type `delta ()` rather than `delta beta` because otherwise information relevant for pretty-printing would be lost.

(<*) :: AbstractSyntax delta => delta alpha -> delta () -> delta alpha infixl 7 Source

This variant of <*> ignores its right result. In contrast to its counterpart derived from the Applicative class, the ignored parts have type `delta ()` rather than `delta beta` because otherwise information relevant for pretty-printing would be lost.

between :: AbstractSyntax delta => delta () -> delta () -> delta alpha -> delta alpha Source

The between function combines *> and <* in the obvious way.

Alternation

(<+>) :: AbstractSyntax delta => delta alpha -> delta beta -> delta (Either alpha beta) infixl 4 Source

The <+> combinator choose one of two syntax.

choice :: AbstractSyntax delta => [delta alpha] -> delta alpha Source

choice a syntax from list.

optional :: AbstractSyntax delta => delta alpha -> delta (Maybe alpha) Source

The optional combinator may parse / print passed syntax.

bool :: AbstractSyntax delta => delta () -> delta Bool Source

The bool combinator parse / print passed syntax or not.

(<$?>) :: AbstractSyntax delta => Iso (a, b) a -> delta (a, Maybe b) -> delta a infix 5 Source

May append not to repeat prefix syntax.

(<?$>) :: AbstractSyntax delta => Iso (a, b) b -> delta (Maybe a, b) -> delta b infix 5 Source

May prepend not to repeat suffix syntax.

Printing

format :: (Syntax tok delta, Eq tok) => [tok] -> delta () Source

The format combinator just print passed tokens or may parse passed tokens. This is useful in cases when just formatting with indents.