Copyright | (c) The University of Glasgow 2002 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | libraries@haskell.org |
Stability | provisional |
Portability | non-portable (uses Text.ParserCombinators.ReadP) |
Safe Haskell | Safe |
Language | Haskell2010 |
This module defines parser combinators for precedence parsing.
Synopsis
- data ReadPrec a
- type Prec = Int
- minPrec :: Prec
- lift :: ReadP a -> ReadPrec a
- prec :: Prec -> ReadPrec a -> ReadPrec a
- step :: ReadPrec a -> ReadPrec a
- reset :: ReadPrec a -> ReadPrec a
- get :: ReadPrec Char
- look :: ReadPrec String
- (+++) :: ReadPrec a -> ReadPrec a -> ReadPrec a
- (<++) :: ReadPrec a -> ReadPrec a -> ReadPrec a
- pfail :: ReadPrec a
- choice :: [ReadPrec a] -> ReadPrec a
- readPrec_to_P :: ReadPrec a -> Int -> ReadP a
- readP_to_Prec :: (Int -> ReadP a) -> ReadPrec a
- readPrec_to_S :: ReadPrec a -> Int -> ReadS a
- readS_to_Prec :: (Int -> ReadS a) -> ReadPrec a
Documentation
Instances
Alternative ReadPrec | Since: base-4.6.0.0 |
Applicative ReadPrec | Since: base-4.6.0.0 |
Defined in GHC.Internal.Text.ParserCombinators.ReadPrec | |
Functor ReadPrec | Since: base-2.1 |
Monad ReadPrec | Since: base-2.1 |
MonadPlus ReadPrec | Since: base-2.1 |
MonadFail ReadPrec | Since: base-4.9.0.0 |
Precedences
Precedence operations
prec :: Prec -> ReadPrec 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 contextn
.
Other operations
All are based directly on their similarly-named ReadP
counterparts.
Consumes and returns the next character. Fails if there is no input left.
look :: ReadPrec String Source #
Look-ahead: returns the part of the input that is left, without consuming it.
(<++) :: 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.