haskell-gi-0.26.17: Generate Haskell bindings for GObject Introspection capable libraries

Safe Haskell | None
Language | Haskell2010

Data.GI.GIR.Parser

Description

The Parser monad.

Synopsis

- type Parser a = ReaderT ParseContext (Except ParseError) a
- data ParseContext = ParseContext {
  - ctxNamespace :: Text
  - treePosition :: [Text]
  - currentElement :: Element
  - knownAliases :: Map Alias Type
  }
- type ParseError = Text
- parseError :: ParseError -> Parser a
- runParser :: Text -> Map Alias Type -> Element -> Parser a -> Either ParseError a
- parseName :: Parser Name
- parseDeprecation :: Parser (Maybe DeprecationInfo)
- parseDocumentation :: Parser Documentation
- parseIntegral :: Integral a => Text -> Parser a
- parseBool :: Text -> Parser Bool
- parseChildrenWithLocalName :: Text -> Parser a -> Parser [a]
- parseAllChildrenWithLocalName :: Text -> Parser a -> Parser [a]
- parseChildrenWithNSName :: GIRXMLNamespace -> Text -> Parser a -> Parser [a]
- getAttr :: Name -> Parser Text
- getAttrWithNamespace :: GIRXMLNamespace -> Name -> Parser Text
- queryAttr :: Name -> Parser (Maybe Text)
- queryAttrWithNamespace :: GIRXMLNamespace -> Name -> Parser (Maybe Text)
- optionalAttr :: Name -> a -> (Text -> Parser a) -> Parser a
- currentNamespace :: Parser Text
- qualifyName :: Text -> Parser Name
- resolveQualifiedTypeName :: Name -> Parser Type
- data Name = Name {
  - namespace :: Text
  - name :: Text
  }
- data Element
- data GIRXMLNamespace
  - = GLibGIRNS
  - | CGIRNS
  - | CoreGIRNS
- data DeprecationInfo
- data Documentation

# Documentation

type Parser a = ReaderT ParseContext (Except ParseError) a Source #

Monad where parsers live: we carry a context around, and can throw errors that abort the parsing.

data ParseContext Source #

Info to carry around when parsing.

Constructors

ParseContext |

Fields

- ctxNamespace :: Text
- treePosition :: [Text]
- currentElement :: Element
- knownAliases :: Map Alias Type

#### Instances

Instances details

Show ParseContext Source # |
Instance details Defined in Data.GI.GIR.Parser Methods showsPrec :: Int -> ParseContext -> ShowS Source # show :: ParseContext -> String Source # showList :: [ParseContext] -> ShowS Source #

type ParseError = Text Source #

A message describing a parsing error in human readable form.

parseError :: ParseError -> Parser a Source #

Throw a parse error.

runParser :: Text -> Map Alias Type -> Element -> Parser a -> Either ParseError a Source #

Run the given parser, returning either success or an error.

parseName :: Parser Name Source #

Get the qualified name for the current element.

parseDeprecation :: Parser (Maybe DeprecationInfo) Source #

Parse the deprecation text, if present.

parseDocumentation :: Parser Documentation Source #

Parse the documentation info for the current node.

parseIntegral :: Integral a => Text -> Parser a Source #

Parse a signed integral number.

parseBool :: Text -> Parser Bool Source #

A boolean value given by a numerical constant.

parseChildrenWithLocalName :: Text -> Parser a -> Parser [a] Source #

Parse all the introspectable subelements with the given local name.

parseAllChildrenWithLocalName :: Text -> Parser a -> Parser [a] Source #

Parse all subelements with the given local name.

parseChildrenWithNSName :: GIRXMLNamespace -> Text -> Parser a -> Parser [a] Source #

Parse all introspectable children with the given namespace and local name.

getAttr :: Name -> Parser Text Source #

Return the value of an attribute for the given element. If the attribute is not present this throws an error.

getAttrWithNamespace :: GIRXMLNamespace -> Name -> Parser Text Source #

Like `getAttr`, but allow for specifying the namespace.

queryAttr :: Name -> Parser (Maybe Text) Source #

Return the value of an attribute if it is present, and Nothing otherwise.

queryAttrWithNamespace :: GIRXMLNamespace -> Name -> Parser (Maybe Text) Source #

Like `queryAttr`, but allow for specifying the namespace.

optionalAttr :: Name -> a -> (Text -> Parser a) -> Parser a Source #

Ask for an optional attribute, applying the given parser to it. If the argument does not exist return the default value provided.

currentNamespace :: Parser Text Source #

Return the current namespace.

qualifyName :: Text -> Parser Name Source #

Build a `Name` out of the (possibly qualified) supplied name. If the supplied name is unqualified we qualify with the current namespace, and otherwise we simply parse it.

resolveQualifiedTypeName :: Name -> Parser Type Source #

Check whether there is an alias for the given name, and return the corresponding type in case it exists, and otherwise a TInterface.

data Name Source #

Name for a symbol in the GIR file.

Constructors

Name |

Fields

- namespace :: Text
- name :: Text

#### Instances

Instances details

Show Name Source # |
Instance details Defined in Data.GI.GIR.BasicTypes Methods showsPrec :: Int -> Name -> ShowS Source # show :: Name -> String Source # showList :: [Name] -> ShowS Source #
Eq Name Source # |
Instance details Defined in Data.GI.GIR.BasicTypes Methods (==) :: Name -> Name -> Bool Source # (/=) :: Name -> Name -> Bool Source #
Ord Name Source # |
Instance details Defined in Data.GI.GIR.BasicTypes Methods compare :: Name -> Name -> Ordering Source # (<) :: Name -> Name -> Bool Source # (<=) :: Name -> Name -> Bool Source # (>) :: Name -> Name -> Bool Source # (>=) :: Name -> Name -> Bool Source # max :: Name -> Name -> Name Source # min :: Name -> Name -> Name Source #

data Element Source #

#### Instances

Instances details

ToMarkup Element | Note that the special element name `{http:/www.snoyman.comxml2html}ie-cond` with the single attribute `cond` is used to indicate an IE conditional comment.
Instance details Defined in Text.XML Methods toMarkup :: Element -> Markup preEscapedToMarkup :: Element -> Markup
NFData Element |
Instance details Defined in Text.XML Methods rnf :: Element -> () Source #
Data Element |

Instance details

Defined in Text.XML

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Element -> c Element Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Element Source #

toConstr :: Element -> Constr Source #

dataTypeOf :: Element -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Element) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Element) Source #

gmapT :: (forall b. Data b => b -> b) -> Element -> Element Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Element -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Element -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Element -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Element -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Element -> m Element Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Element -> m Element Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Element -> m Element Source #

Show Element |
Instance details Defined in Text.XML Methods showsPrec :: Int -> Element -> ShowS Source # show :: Element -> String Source # showList :: [Element] -> ShowS Source #
Eq Element |
Instance details Defined in Text.XML Methods (==) :: Element -> Element -> Bool Source # (/=) :: Element -> Element -> Bool Source #
Ord Element |
Instance details Defined in Text.XML Methods compare :: Element -> Element -> Ordering Source # (<) :: Element -> Element -> Bool Source # (<=) :: Element -> Element -> Bool Source # (>) :: Element -> Element -> Bool Source # (>=) :: Element -> Element -> Bool Source # max :: Element -> Element -> Element Source # min :: Element -> Element -> Element Source #

data GIRXMLNamespace Source #

GIR namespaces we know about.

Constructors

GLibGIRNS |
CGIRNS |
CoreGIRNS |

#### Instances

Instances details

Show GIRXMLNamespace Source # |
Instance details Defined in Data.GI.GIR.XMLUtils Methods showsPrec :: Int -> GIRXMLNamespace -> ShowS Source # show :: GIRXMLNamespace -> String Source # showList :: [GIRXMLNamespace] -> ShowS Source #

data DeprecationInfo Source #

Deprecation information on a symbol.

#### Instances

Instances details

Show DeprecationInfo Source # |
Instance details Defined in Data.GI.GIR.Deprecation Methods showsPrec :: Int -> DeprecationInfo -> ShowS Source # show :: DeprecationInfo -> String Source # showList :: [DeprecationInfo] -> ShowS Source #
Eq DeprecationInfo Source # |
Instance details Defined in Data.GI.GIR.Deprecation Methods (==) :: DeprecationInfo -> DeprecationInfo -> Bool Source # (/=) :: DeprecationInfo -> DeprecationInfo -> Bool Source #

data Documentation Source #

Documentation for a given element. The documentation text is typically encoded in the gtk-doc format, see https://developer.gnome.org/gtk-doc-manual/ . This can be parsed with `parseGtkDoc`.

#### Instances

Instances details

Show Documentation Source # |
Instance details Defined in Data.GI.GIR.Documentation Methods showsPrec :: Int -> Documentation -> ShowS Source # show :: Documentation -> String Source # showList :: [Documentation] -> ShowS Source #
Eq Documentation Source # |
Instance details Defined in Data.GI.GIR.Documentation Methods (==) :: Documentation -> Documentation -> Bool Source # (/=) :: Documentation -> Documentation -> Bool Source #
Ord Documentation Source # |

Instance details

Defined in Data.GI.GIR.Documentation

Methods

compare :: Documentation -> Documentation -> Ordering Source #

(<) :: Documentation -> Documentation -> Bool Source #

(<=) :: Documentation -> Documentation -> Bool Source #

(>) :: Documentation -> Documentation -> Bool Source #

(>=) :: Documentation -> Documentation -> Bool Source #

max :: Documentation -> Documentation -> Documentation Source #

min :: Documentation -> Documentation -> Documentation Source #