polyparse-1.13.1: A variety of alternative parser combinator libraries.

Copyright | Graham Hutton (University of Nottingham) Erik Meijer (University of Utrecht)
License | BSD
Maintainer | Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk>
Stability | Stable
Portability | All A LIBRARY OF MONADIC PARSER COMBINATORS 29th July 1996 Graham Hutton Erik Meijer University of Nottingham University of Utrecht
Safe Haskell | Safe-Inferred
Language | Haskell2010

Text.ParserCombinators.HuttonMeijer

Description

This Haskell script defines a library of parser combinators, and is taken from sections 1-6 of our article "Monadic Parser Combinators". Some changes to the library have been made in the move from Gofer to Haskell:

- Do notation is used in place of monad comprehension notation;
- The parser datatype is defined using "newtype", to avoid the overhead of tagging and untagging parsers with the P constructor.

Synopsis

- newtype Parser a = P ([Token] -> [(a, [Token])])
- item :: Parser Token
- first :: Parser a -> Parser a
- papply :: Parser a -> [Token] -> [(a, [Token])]
- (+++) :: Parser a -> Parser a -> Parser a
- sat :: (Token -> Bool) -> Parser Token
- many :: Parser a -> Parser [a]
- many1 :: Parser a -> Parser [a]
- sepby :: Parser a -> Parser b -> Parser [a]
- sepby1 :: Parser a -> Parser b -> Parser [a]
- chainl :: Parser a -> Parser (a -> a -> a) -> a -> Parser a
- chainl1 :: Parser a -> Parser (a -> a -> a) -> Parser a
- chainr :: Parser a -> Parser (a -> a -> a) -> a -> Parser a
- chainr1 :: Parser a -> Parser (a -> a -> a) -> Parser a
- ops :: [(Parser a, b)] -> Parser b
- bracket :: Parser a -> Parser b -> Parser c -> Parser b
- char :: Char -> Parser Char
- digit :: Parser Char
- lower :: Parser Char
- upper :: Parser Char
- letter :: Parser Char
- alphanum :: Parser Char
- string :: String -> Parser String
- ident :: Parser String
- nat :: Parser Int
- int :: Parser Int
- spaces :: Parser ()
- comment :: Parser ()
- junk :: Parser ()
- skip :: Parser a -> Parser a
- token :: Parser a -> Parser a
- natural :: Parser Int
- integer :: Parser Int
- symbol :: String -> Parser String
- identifier :: [String] -> Parser String

# Documentation

newtype Parser a Source #

The parser monad

Constructors

P ([Token] -> [(a, [Token])]) |

#### Instances

Instances details

Alternative Parser Source # |
Instance details Defined in Text.ParserCombinators.HuttonMeijer Methods empty :: Parser a Source # (<|>) :: Parser a -> Parser a -> Parser a Source # some :: Parser a -> Parser [a] Source # many :: Parser a -> Parser [a] Source #
Applicative Parser Source # |
Instance details Defined in Text.ParserCombinators.HuttonMeijer Methods pure :: a -> Parser a Source # (<*>) :: Parser (a -> b) -> Parser a -> Parser b Source # liftA2 :: (a -> b -> c) -> Parser a -> Parser b -> Parser c Source # (*>) :: Parser a -> Parser b -> Parser b Source # (<*) :: Parser a -> Parser b -> Parser a Source #
Functor Parser Source # |
Instance details Defined in Text.ParserCombinators.HuttonMeijer Methods fmap :: (a -> b) -> Parser a -> Parser b Source # (<$) :: a -> Parser b -> Parser a Source #
Monad Parser Source # |
Instance details Defined in Text.ParserCombinators.HuttonMeijer Methods (>>=) :: Parser a -> (a -> Parser b) -> Parser b Source # (>>) :: Parser a -> Parser b -> Parser b Source # return :: a -> Parser a Source #
MonadPlus Parser Source # |
Instance details Defined in Text.ParserCombinators.HuttonMeijer Methods mzero :: Parser a Source # mplus :: Parser a -> Parser a -> Parser a Source #
MonadFail Parser Source # |
Instance details Defined in Text.ParserCombinators.HuttonMeijer Methods fail :: String -> Parser a Source #

item :: Parser Token Source #

first :: Parser a -> Parser a Source #

papply :: Parser a -> [Token] -> [(a, [Token])] Source #

(+++) :: Parser a -> Parser a -> Parser a infixr 5 Source #

sat :: (Token -> Bool) -> Parser Token Source #

many :: Parser a -> Parser [a] Source #

many1 :: Parser a -> Parser [a] Source #

sepby :: Parser a -> Parser b -> Parser [a] Source #

sepby1 :: Parser a -> Parser b -> Parser [a] Source #

chainl :: Parser a -> Parser (a -> a -> a) -> a -> Parser a Source #

chainl1 :: Parser a -> Parser (a -> a -> a) -> Parser a Source #

chainr :: Parser a -> Parser (a -> a -> a) -> a -> Parser a Source #

chainr1 :: Parser a -> Parser (a -> a -> a) -> Parser a Source #

ops :: [(Parser a, b)] -> Parser b Source #

bracket :: Parser a -> Parser b -> Parser c -> Parser b Source #

char :: Char -> Parser Char Source #

digit :: Parser Char Source #

lower :: Parser Char Source #

upper :: Parser Char Source #

letter :: Parser Char Source #

alphanum :: Parser Char Source #

string :: String -> Parser String Source #

ident :: Parser String Source #

nat :: Parser Int Source #

int :: Parser Int Source #

spaces :: Parser () Source #

comment :: Parser () Source #

junk :: Parser () Source #

skip :: Parser a -> Parser a Source #

token :: Parser a -> Parser a Source #

natural :: Parser Int Source #

integer :: Parser Int Source #

symbol :: String -> Parser String Source #

identifier :: [String] -> Parser String Source #