parsec-2.1.0.1: Monadic parser combinatorsSource codeContentsIndex
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 aSource
(<|>) :: GenParser tok st a -> GenParser tok st a -> GenParser tok st aSource
type Parser a = GenParser Char () aSource
data GenParser tok st a Source
show/hide Instances
runParser :: GenParser tok st a -> st -> SourceName -> [tok] -> Either ParseError aSource
parse :: GenParser tok () a -> SourceName -> [tok] -> Either ParseError aSource
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 aSource
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 aSource
tokenPrimEx :: (tok -> String) -> (SourcePos -> tok -> [tok] -> SourcePos) -> Maybe (SourcePos -> tok -> [tok] -> st -> st) -> (tok -> Maybe a) -> GenParser tok st aSource
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 aSource
label :: GenParser tok st a -> String -> GenParser tok st aSource
labels :: GenParser tok st a -> [String] -> GenParser tok st aSource
unexpected :: String -> GenParser tok st aSource
pzero :: GenParser tok st aSource
many :: GenParser tok st a -> GenParser tok st [a]Source
skipMany :: GenParser tok st a -> GenParser tok st ()Source
getState :: GenParser tok st stSource
setState :: st -> GenParser tok st ()Source
updateState :: (st -> st) -> GenParser tok st ()Source
getPosition :: GenParser tok st SourcePosSource
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 2.4.2