Safe Haskell | None |
---|
Parser combinators.
- string :: Stream s m Token => Text -> ParsecT s u m Text
- genitive :: Stream s m Token => ParsecT s u m Bool
- number :: Stream s m Token => ParsecT s u m Integer
- quoted :: Stream s m Token => ParsecT s u m Text
- comma :: Stream s m Token => ParsecT s u m ()
- period :: Stream s m Token => ParsecT s u m ()
- strings :: Stream s m Token => [Text] -> ParsecT s u m ()
- satisfy :: Stream s m Token => (Token -> Maybe a) -> ParsecT s u m a
- anyToken :: Stream s m Token => ParsecT s u m Token
- tokenString :: Token -> [Char]
- tokenPosition :: SourcePos -> Token -> t -> SourcePos
- notFollowedBy :: Stream s m Token => ParsecT s u m Token -> ParsecT s u m ()
- eof :: Stream s m Token => ParsecT s u m ()
Documentation
strings :: Stream s m Token => [Text] -> ParsecT s u m ()Source
Try to match all the given strings, or none at all.
satisfy :: Stream s m Token => (Token -> Maybe a) -> ParsecT s u m aSource
Satisfy the given predicate from the token stream.
anyToken :: Stream s m Token => ParsecT s u m TokenSource
The parser anyToken
accepts any kind of token. It is for example
used to implement eof
. Returns the accepted token.
tokenString :: Token -> [Char]Source
Make a string out of the token, for error message purposes.
tokenPosition :: SourcePos -> Token -> t -> SourcePosSource
Update the position by the token.
notFollowedBy :: Stream s m Token => ParsecT s u m Token -> ParsecT s u m ()Source
notFollowedBy p
only succeeds when parser p
fails. This parser
does not consume any input. This parser can be used to implement the
'longest match' rule. For example, when recognizing keywords (for
example let
), we want to make sure that a keyword is not followed
by a legal identifier character, in which case the keyword is
actually an identifier (for example lets
). We can program this
behaviour as follows:
keywordLet = try (do{ string "let" ; notFollowedBy alphaNum })