| parsec-2.1.0.1: Monadic parser combinators | Source code | Contents | Index
Text.ParserCombinators.Parsec.Prim |
Portability | portable
Stability | provisional
Maintainer | daan@cs.uu.nl
Description
The primitive parser combinators.
Synopsis
(<?>) :: GenParser tok st a -> String -> GenParser tok st a
(<|>) :: GenParser tok st a -> GenParser tok st a -> GenParser tok st a
type Parser a = GenParser Char () a
data GenParser tok st a
runParser :: GenParser tok st a -> st -> SourceName -> [tok] -> Either ParseError a
parse :: GenParser tok () a -> SourceName -> [tok] -> Either ParseError a
parseFromFile :: Parser a -> SourceName -> IO (Either ParseError a)
parseTest :: Show a => GenParser tok () a -> [tok] -> IO ()
token :: (tok -> String) -> (tok -> SourcePos) -> (tok -> Maybe a) -> GenParser tok st a
tokens :: Eq tok => ([tok] -> String) -> (SourcePos -> [tok] -> SourcePos) -> [tok] -> GenParser tok st [tok]
tokenPrim :: (tok -> String) -> (SourcePos -> tok -> [tok] -> SourcePos) -> (tok -> Maybe a) -> GenParser tok st a
tokenPrimEx :: (tok -> String) -> (SourcePos -> tok -> [tok] -> SourcePos) -> Maybe (SourcePos -> tok -> [tok] -> st -> st) -> (tok -> Maybe a) -> GenParser tok st a
try :: GenParser tok st a -> GenParser tok st a
label :: GenParser tok st a -> String -> GenParser tok st a
labels :: GenParser tok st a -> [String] -> GenParser tok st a
unexpected :: String -> GenParser tok st a
pzero :: GenParser tok st a
many :: GenParser tok st a -> GenParser tok st [a]
skipMany :: GenParser tok st a -> GenParser tok st ()
getState :: GenParser tok st st
setState :: st -> GenParser tok st ()
updateState :: (st -> st) -> GenParser tok st ()
getPosition :: GenParser tok st SourcePos
setPosition :: SourcePos -> GenParser tok st ()
getInput :: GenParser tok st [tok]
setInput :: [tok] -> GenParser tok st ()
data State tok st = State {
stateInput :: [tok]
statePos :: !SourcePos
stateUser :: !st
}
getParserState :: GenParser tok st (State tok st)
setParserState :: State tok st -> GenParser tok st (State tok st)
Documentation
(<?>) :: GenParser tok st a -> String -> GenParser tok st a | Source
(<|>) :: GenParser tok st a -> GenParser tok st a -> GenParser tok st a | Source
type Parser a = GenParser Char () a | Source
data GenParser tok st a | Source
Instances
Functor (GenParser tok st)
Monad (GenParser tok st)
MonadPlus (GenParser tok st)
runParser :: GenParser tok st a -> st -> SourceName -> [tok] -> Either ParseError a | Source
parse :: GenParser tok () a -> SourceName -> [tok] -> Either ParseError a | Source
parseFromFile :: Parser a -> SourceName -> IO (Either ParseError a) | Source
parseTest :: Show a => GenParser tok () a -> [tok] -> IO () | Source
token :: (tok -> String) -> (tok -> SourcePos) -> (tok -> Maybe a) -> GenParser tok st a | Source
tokens :: Eq tok => ([tok] -> String) -> (SourcePos -> [tok] -> SourcePos) -> [tok] -> GenParser tok st [tok] | Source
tokenPrim :: (tok -> String) -> (SourcePos -> tok -> [tok] -> SourcePos) -> (tok -> Maybe a) -> GenParser tok st a | Source
tokenPrimEx :: (tok -> String) -> (SourcePos -> tok -> [tok] -> SourcePos) -> Maybe (SourcePos -> tok -> [tok] -> st -> st) -> (tok -> Maybe a) -> GenParser tok st a | Source
The most primitive token recogniser. The expression `tokenPrimEx show nextpos mbnextstate test`, recognises tokens when `test` returns `Just x` (and returns the value `x`). Tokens are shown in error messages using `show`. The position is calculated using `nextpos`, and finally, `mbnextstate`, can hold a function that updates the user state on every token recognised (nice to count tokens :-). The function is packed into a `Maybe` type for performance reasons.
try :: GenParser tok st a -> GenParser tok st a | Source
label :: GenParser tok st a -> String -> GenParser tok st a | Source
labels :: GenParser tok st a -> [String] -> GenParser tok st a | Source
unexpected :: String -> GenParser tok st a | Source
pzero :: GenParser tok st a | Source
many :: GenParser tok st a -> GenParser tok st [a] | Source
skipMany :: GenParser tok st a -> GenParser tok st () | Source
getState :: GenParser tok st st | Source
setState :: st -> GenParser tok st () | Source
updateState :: (st -> st) -> GenParser tok st () | Source
getPosition :: GenParser tok st SourcePos | Source
setPosition :: SourcePos -> GenParser tok st () | Source
getInput :: GenParser tok st [tok] | Source
setInput :: [tok] -> GenParser tok st () | Source
data State tok st | Source
Constructors
State |
stateInput :: [tok] |
statePos :: !SourcePos |
stateUser :: !st |
getParserState :: GenParser tok st (State tok st) | Source
setParserState :: State tok st -> GenParser tok st (State tok st) | Source
Produced by Haddock version 0.9