hextream-0.3.0.0: Streaming-friendly XML parsers
Safe HaskellNone
LanguageHaskell2010

Data.XML.InternalSubset.Parser.Mid

Description

Mid-level parsers for doctype's internal subset, built on top of Data.XML.InternalSubset.Parser.Low:

  • some formatting details are abstracted away (e.g. quoting, whitespacing), therefore parsers are not reversible
  • entities delimited by an opening and closing sequence are recognized
  • token parsers do not overlap, therefore XML document can be tokenized in a stateless way

All documentation examples assume the following setup:

:set -XOverloadedStrings
import Data.Attoparsec.ByteString
Synopsis

Documentation

data TokenParser m a Source #

A parser that consumes whole Tokens.

Instances

Instances details
Monad m => Monad (TokenParser m) Source # 
Instance details

Defined in Data.XML.InternalSubset.Parser.Mid

Methods

(>>=) :: TokenParser m a -> (a -> TokenParser m b) -> TokenParser m b #

(>>) :: TokenParser m a -> TokenParser m b -> TokenParser m b #

return :: a -> TokenParser m a #

Functor m => Functor (TokenParser m) Source # 
Instance details

Defined in Data.XML.InternalSubset.Parser.Mid

Methods

fmap :: (a -> b) -> TokenParser m a -> TokenParser m b #

(<$) :: a -> TokenParser m b -> TokenParser m a #

(Parsing m, Monad m) => MonadFail (TokenParser m) Source # 
Instance details

Defined in Data.XML.InternalSubset.Parser.Mid

Methods

fail :: String -> TokenParser m a #

Applicative m => Applicative (TokenParser m) Source # 
Instance details

Defined in Data.XML.InternalSubset.Parser.Mid

Methods

pure :: a -> TokenParser m a #

(<*>) :: TokenParser m (a -> b) -> TokenParser m a -> TokenParser m b #

liftA2 :: (a -> b -> c) -> TokenParser m a -> TokenParser m b -> TokenParser m c #

(*>) :: TokenParser m a -> TokenParser m b -> TokenParser m b #

(<*) :: TokenParser m a -> TokenParser m b -> TokenParser m a #

Alternative m => Alternative (TokenParser m) Source # 
Instance details

Defined in Data.XML.InternalSubset.Parser.Mid

Methods

empty :: TokenParser m a #

(<|>) :: TokenParser m a -> TokenParser m a -> TokenParser m a #

some :: TokenParser m a -> TokenParser m [a] #

many :: TokenParser m a -> TokenParser m [a] #

tokenElementType :: CharParsing m => Monad m => TokenParser m ElementType Source #

https://www.w3.org/TR/REC-xml/#NT-elementdecl

>>> parseOnly (runTokenParser tokenElementType) "<!ELEMENT br EMPTY>"
Right (ElementType "br" ContentEmpty)
>>> parseOnly (runTokenParser tokenElementType) "<!ELEMENT container ANY>"
Right (ElementType "container" ContentAny)

tokenAttributeList :: CharParsing m => Monad m => TokenParser m AttributeList Source #

https://www.w3.org/TR/REC-xml/#NT-AttlistDecl

>>> parseOnly (runTokenParser tokenAttributeList) "<!ATTLIST termdef>"
Right (AttributeList "termdef")

tokenGeneralEntity :: CharParsing m => Monad m => TokenParser m GeneralEntity Source #

https://www.w3.org/TR/REC-xml/#NT-GEDecl

>>> parseOnly (runTokenParser tokenGeneralEntity) "<!ENTITY d '&#xD;'>"
Right (GeneralEntity "d" [ContentReference (CharRef '\r')])
>>> parseOnly (runTokenParser tokenGeneralEntity) "<!ENTITY da '&#xD;&#xA;'>"
Right (GeneralEntity "da" [ContentReference (CharRef '\r'),ContentReference (CharRef '\n')])
>>> parseOnly (runTokenParser tokenGeneralEntity) "<!ENTITY Pub-Status 'This is a pre-release of the specification.'>"
Right (GeneralEntity "Pub-Status" [ContentText "This is a pre-release of the specification."])

tokenParameterEntity :: CharParsing m => Monad m => TokenParser m ParameterEntity Source #

https://www.w3.org/TR/REC-xml/#NT-PEDecl

>>> parseOnly (runTokenParser tokenParameterEntity) "<!ENTITY % YN '\"Yes\"' >"
Right (ParameterEntity "YN" [ValueText "\"Yes\""])

tokenNotation :: CharParsing m => Monad m => TokenParser m Notation Source #

https://www.w3.org/TR/REC-xml/#NT-NotationDecl

>>> parseOnly (runTokenParser tokenNotation) "<!NOTATION foo SYSTEM \"identifier\">"
Right (Notation "foo" (SystemID "identifier"))