Safe Haskell | None |
---|---|
Language | Haskell2010 |
Useful common functions for building parsers
- properName :: TokenParser (ProperName a)
- typeName :: TokenParser (ProperName TypeName)
- kindName :: TokenParser (ProperName KindName)
- dataConstructorName :: TokenParser (ProperName ConstructorName)
- moduleName :: TokenParser ModuleName
- parseQualified :: TokenParser a -> TokenParser (Qualified a)
- parseIdent :: TokenParser Ident
- parseLabel :: TokenParser PSString
- parseOperator :: TokenParser (OpName a)
- augment :: Stream s m t => ParsecT s u m a -> ParsecT s u m b -> (a -> b -> a) -> ParsecT s u m a
- fold :: ParsecT s u m a -> ParsecT s u m b -> (a -> b -> a) -> ParsecT s u m a
- buildPostfixParser :: Stream s m t => [a -> ParsecT s u m a] -> ParsecT s u m a -> ParsecT s u m a
- mark :: Parsec s ParseState a -> Parsec s ParseState a
- checkIndentation :: (Column -> Text) -> (Column -> Column -> Bool) -> Parsec s ParseState ()
- indented :: Parsec s ParseState ()
- same :: Parsec s ParseState ()
- readComments :: Parsec [PositionedToken] u [Comment]
- runTokenParser :: FilePath -> TokenParser a -> [PositionedToken] -> Either ParseError a
- toSourcePos :: SourcePos -> SourcePos
- withSourceSpan :: (SourceSpan -> [Comment] -> a -> b) -> Parsec [PositionedToken] u a -> Parsec [PositionedToken] u b
- withSourceAnnF :: Parsec [PositionedToken] u (SourceAnn -> a) -> Parsec [PositionedToken] u a
- withSourceSpan' :: (SourceSpan -> a -> b) -> Parsec [PositionedToken] u a -> Parsec [PositionedToken] u b
Documentation
properName :: TokenParser (ProperName a) Source #
Parse a general proper name.
typeName :: TokenParser (ProperName TypeName) Source #
Parse a proper name for a type.
kindName :: TokenParser (ProperName KindName) Source #
Parse a proper name for a kind.
dataConstructorName :: TokenParser (ProperName ConstructorName) Source #
Parse a proper name for a data constructor.
moduleName :: TokenParser ModuleName Source #
Parse a module name
parseQualified :: TokenParser a -> TokenParser (Qualified a) Source #
Parse a qualified name, i.e. M.name or just name
parseIdent :: TokenParser Ident Source #
Parse an identifier.
parseLabel :: TokenParser PSString Source #
Parse a label, which may look like an identifier or a string
parseOperator :: TokenParser (OpName a) Source #
Parse an operator.
augment :: Stream s m t => ParsecT s u m a -> ParsecT s u m b -> (a -> b -> a) -> ParsecT s u m a Source #
Run the first parser, then match the second if possible, applying the specified function on a successful match
fold :: ParsecT s u m a -> ParsecT s u m b -> (a -> b -> a) -> ParsecT s u m a Source #
Run the first parser, then match the second zero or more times, applying the specified function for each match
buildPostfixParser :: Stream s m t => [a -> ParsecT s u m a] -> ParsecT s u m a -> ParsecT s u m a Source #
Build a parser from a smaller parser and a list of parsers for postfix operators
mark :: Parsec s ParseState a -> Parsec s ParseState a Source #
Mark the current indentation level
checkIndentation :: (Column -> Text) -> (Column -> Column -> Bool) -> Parsec s ParseState () Source #
Check that the current identation level matches a predicate
indented :: Parsec s ParseState () Source #
Check that the current indentation level is past the current mark
same :: Parsec s ParseState () Source #
Check that the current indentation level is at the same indentation as the current mark
readComments :: Parsec [PositionedToken] u [Comment] Source #
Read the comments from the the next token, without consuming it
runTokenParser :: FilePath -> TokenParser a -> [PositionedToken] -> Either ParseError a Source #
Run a parser
toSourcePos :: SourcePos -> SourcePos Source #
Convert from Parsec sourcepos
withSourceSpan :: (SourceSpan -> [Comment] -> a -> b) -> Parsec [PositionedToken] u a -> Parsec [PositionedToken] u b Source #
Read source position information and comments
withSourceAnnF :: Parsec [PositionedToken] u (SourceAnn -> a) -> Parsec [PositionedToken] u a Source #
withSourceSpan' :: (SourceSpan -> a -> b) -> Parsec [PositionedToken] u a -> Parsec [PositionedToken] u b Source #