parsec-2.1.0.0: Monadic parser combinatorsContentsIndex
Text.ParserCombinators.Parsec.Prim
Portabilityportable
Stabilityprovisional
Maintainerdaan@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
(<|>) :: GenParser tok st a -> GenParser tok st a -> GenParser tok st a
type Parser a = GenParser Char () a
data GenParser tok st a
show/hide Instances
Functor (GenParser tok st)
Monad (GenParser tok st)
MonadPlus (GenParser tok st)
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
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
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
Constructors
State
stateInput :: [tok]
statePos :: !SourcePos
stateUser :: !st
getParserState :: GenParser tok st (State tok st)
setParserState :: State tok st -> GenParser tok st (State tok st)
Produced by Haddock version 0.8