tagsoup-megaparsec-0.2.0.0: A Tag token parser and Tag specific parsing combinators

Copyright© 2016 Kwang Yul Seo
LicenseBSD
MaintainerKwang Yul Seo <kwangyul.seo@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Text.Megaparsec.TagSoup

Contents

Description

Make Tags an instance of Stream with 'Tag str' token type.

Synopsis

Documentation

type TagParser str = Parsec Dec [Tag str] Source #

Different modules corresponding to various types of streams (String, Text, ByteString) define it differently, so user can use “abstract” Parser type and easily change it by importing different “type modules”. This one is for TagSoup tags.

space :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str) Source #

Parses a text block containing only characters which satisfy isSpace.

whitespace :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m () Source #

Parses any whitespace. Whitespace consists of zero or more ocurrences of space.

lexeme :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str) -> m (Tag str) Source #

lexeme p first applies parser p and then whitespace, returning the value of p.

lexeme = (<* whitespace)

Every tag parser is defined using lexeme, this way every parse starts at a point without whitespace.

The only point where whitespace should be called explicitly is at the start of the top level parser, in order to skip any leading whitespace.

satisfy :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => (Tag str -> Bool) -> m (Tag str) Source #

Parse a tag if it satisfies the predicate. As all the tag parsers, it consumes the whitespace immediately after the parsed tag.

anyTag :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str) Source #

Parses any tag. As all the tag parsers, it consumes the whitespace immediately after the parsed tag.

anyTagOpen :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str) Source #

Parse any opening tag. As all the tag parsers, it consumes the whitespace immediately after the parsed tag.

anyTagClose :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str) Source #

Parse any closing tag. As all the tag parsers, it consumes the whitespace immediately after the parsed tag.

tagText :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str) Source #

Parses a chunk of text. As all the tag parsers, it consumes the whitespace immediately after the parsed tag.

tagOpen :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => str -> m (Tag str) Source #

Parse the given opening tag. As all the tag parsers, these consume the whitespace immediately after the parsed tag.

tagClose :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => str -> m (Tag str) Source #

Parse the given closing tag. As all the tag parsers, these consume the whitespace immediately after the parsed tag.

Orphan instances

Ord str => Stream [Tag str] Source # 

Associated Types

type Token [Tag str] :: * #

Methods

uncons :: [Tag str] -> Maybe (Token [Tag str], [Tag str]) #

updatePos :: Proxy * [Tag str] -> Pos -> SourcePos -> Token [Tag str] -> (SourcePos, SourcePos) #

Show str => ShowToken (Tag str) Source # 

Methods

showTokens :: NonEmpty (Tag str) -> String #