base-4.7.0.0: Basic libraries

Copyright(c) The University of Glasgow 2002
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityprovisional
Portabilitynon-portable (uses Text.ParserCombinators.ReadP)
Safe HaskellTrustworthy
LanguageHaskell2010

Text.ParserCombinators.ReadPrec

Contents

Description

This library defines parser combinators for precedence parsing.

Synopsis

Documentation

Precedences

type Prec = Int Source

Precedence operations

liftReadP a → ReadPrec a Source

Lift a precedence-insensitive ReadP to a ReadPrec.

precPrecReadPrec a → ReadPrec a Source

(prec n p) checks whether the precedence context is less than or equal to n, and

  • if not, fails
  • if so, parses p in context n.

stepReadPrec a → ReadPrec a Source

Increases the precedence context by one.

resetReadPrec a → ReadPrec a Source

Resets the precedence context to zero.

Other operations

All are based directly on their similarly-named ReadP counterparts.

getReadPrec Char Source

Consumes and returns the next character. Fails if there is no input left.

lookReadPrec String Source

Look-ahead: returns the part of the input that is left, without consuming it.

(+++)ReadPrec a → ReadPrec a → ReadPrec a Source

Symmetric choice.

(<++)ReadPrec a → ReadPrec a → ReadPrec a Source

Local, exclusive, left-biased choice: If left parser locally produces any result at all, then right parser is not used.

pfailReadPrec a Source

Always fails.

choice ∷ [ReadPrec a] → ReadPrec a Source

Combines all parsers in the specified list.

Converters