Data.GraphViz.Parsing

graphviz-2999.18.1.0: Bindings to Graphviz for graph visualisation.

Copyright | (c) Matthew Sackman, Ivan Lazar Miljenovic
License | 3-Clause BSD-style
Maintainer | Ivan.Miljenovic@gmail.com
Safe Haskell | Safe
Language | Haskell2010

Data.GraphViz.Parsing

Contents

- Re-exporting pertinent parts of Polyparse.
- The ParseDot class.
- Convenience parsing combinators.

Description

This module defines simple helper functions for use with Text.ParserCombinators.Poly.Lazy.

Note that the `ParseDot` instances for `Bool`, etc. match those specified for use with Graphviz (e.g. non-zero integers are equivalent to `True`).

You should not be using this module; rather, it is here for informative/documentative reasons. If you want to parse a ``DotRepr``, you should use ``parseDotGraph`` rather than its `ParseDot` instance.

Synopsis

- module Text.ParserCombinators.Poly.StateText
- type Parse a = Parser GraphvizState a
- class ParseDot a where
  - parseUnqt :: Parse a
  - parse :: Parse a
  - parseUnqtList :: Parse [a]
  - parseList :: Parse [a]
- parseIt :: ParseDot a => Text -> (a, Text)
- parseIt' :: ParseDot a => Text -> a
- runParser :: Parse a -> Text -> (Either String a, Text)
- runParser' :: Parse a -> Text -> a
- runParserWith :: (GraphvizState -> GraphvizState) -> Parse a -> Text -> (Either String a, Text)
- parseLiberally :: GraphvizState -> GraphvizState
- checkValidParse :: Either String a -> a
- ignoreSep :: (a -> b -> c) -> Parse a -> Parse sep -> Parse b -> Parse c
- onlyBool :: Parse Bool
- quotelessString :: Parse Text
- stringBlock :: Parse Text
- numString :: Bool -> Parse Text
- isNumString :: Text -> Bool
- isIntString :: Text -> Bool
- quotedString :: Parse Text
- parseEscaped :: Bool -> [Char] -> [Char] -> Parse Text
- parseAndSpace :: Parse a -> Parse a
- string :: String -> Parse ()
- strings :: [String] -> Parse ()
- character :: Char -> Parse Char
- parseStrictFloat :: Bool -> Parse Double
- parseSignedFloat :: Bool -> Parse Double
- noneOf :: [Char] -> Parse Char
- whitespace1 :: Parse ()
- whitespace :: Parse ()
- wrapWhitespace :: Parse a -> Parse a
- optionalQuotedString :: String -> Parse ()
- optionalQuoted :: Parse a -> Parse a
- quotedParse :: Parse a -> Parse a
- orQuote :: Parse Char -> Parse Char
- quoteChar :: Char
- newline :: Parse ()
- newline' :: Parse ()
- parseComma :: Parse ()
- parseEq :: Parse ()
- tryParseList :: ParseDot a => Parse [a]
- tryParseList' :: Parse [a] -> Parse [a]
- consumeLine :: Parse Text
- commaSep :: (ParseDot a, ParseDot b) => Parse (a, b)
- commaSepUnqt :: (ParseDot a, ParseDot b) => Parse (a, b)
- commaSep' :: Parse a -> Parse b -> Parse (a, b)
- stringRep :: a -> String -> Parse a
- stringReps :: a -> [String] -> Parse a
- stringParse :: [(String, Parse a)] -> Parse a
- stringValue :: [(String, a)] -> Parse a
- parseAngled :: Parse a -> Parse a
- parseBraced :: Parse a -> Parse a
- parseColorScheme :: Bool -> Parse ColorScheme

# Re-exporting pertinent parts of Polyparse.

module Text.ParserCombinators.Poly.StateText

# The ParseDot class.

type Parse a = Parser GraphvizState a

A `ReadS`-like type alias.

class ParseDot a where

Minimal complete definition

parseUnqt

Methods

parseUnqt :: Parse a

parse :: Parse a

parseUnqtList :: Parse [a]

parseList :: Parse [a]

Instances

ParseDot Bool |
ParseDot Char |
ParseDot Double |
ParseDot Int |
ParseDot Integer |
ParseDot Word8 |
ParseDot Word16 |
ParseDot Version | Ignores `versionTags` and assumes 'not . null . versionBranch' (usually you want 'length . versionBranch == 2') and that all such values are non-negative.
ParseDot Text |
ParseDot BrewerName |
ParseDot BrewerScheme |
ParseDot ColorScheme |
ParseDot GraphvizCommand |
ParseDot X11Color |
ParseDot CompassPoint |
ParseDot PortPos |
ParseDot PortName |
ParseDot SVGColor |
ParseDot ArrowSide |
ParseDot ArrowFill |
ParseDot ArrowModifier |
ParseDot ArrowShape |
ParseDot ArrowType |
ParseDot WeightedColor |
ParseDot Color |
ParseDot Scale |
ParseDot VAlign |
ParseDot Align |
ParseDot Attribute |
ParseDot Img |
ParseDot Cell |
ParseDot Row |
ParseDot Table |
ParseDot Format |
ParseDot TextItem |
ParseDot Label |
ParseDot NodeSize |
ParseDot Normalized |
ParseDot Number |
ParseDot Ratios |
ParseDot Justification |
ParseDot ScaleType |
ParseDot Paths |
ParseDot VerticalPlacement |
ParseDot FocusType |
ParseDot ViewPort |
ParseDot StyleName |
ParseDot StyleItem |
ParseDot STStyle |
ParseDot StartType |
ParseDot SmoothType |
ParseDot Shape |
ParseDot RankDir |
ParseDot RankType |
ParseDot Root |
ParseDot QuadType |
ParseDot Spline |
ParseDot PageDir |
ParseDot EdgeType |
ParseDot Pos |
ParseDot PackMode |
ParseDot Pack |
ParseDot OutputMode |
ParseDot Order |
ParseDot LayerList |
ParseDot LayerID |
ParseDot LayerRangeElem |
ParseDot LayerListSep |
ParseDot LayerSep |
ParseDot Overlap | Note that `overlap=false` defaults to ``PrismOverlap` Nothing`, but if the Prism library isn't available then it is equivalent to `VoronoiOverlap`.
ParseDot Point |
ParseDot LabelScheme |
ParseDot RecordField |
ParseDot Label |
ParseDot Model |
ParseDot ModeType |
ParseDot GraphSize |
ParseDot SVGFontNames |
ParseDot DPoint |
ParseDot DEConstraints |
ParseDot DirType |
ParseDot ClusterMode |
ParseDot Rect |
ParseDot Attribute |
ParseDot GlobalAttributes |
ParseDot GraphID |
ParseDot a => ParseDot [a] |
ParseDot n => ParseDot (DotEdge n) |
ParseDot n => ParseDot (DotNode n) |
ParseDot n => ParseDot (DotSubGraph n) |
ParseDot n => ParseDot (DotStatements n) |
ParseDot n => ParseDot (DotGraph n) |
ParseDot n => ParseDot (DotSubGraph n) |
ParseDot n => ParseDot (DotStatement n) |
ParseDot n => ParseDot (DotGraph n) |
(Ord n, ParseDot n) => ParseDot (DotGraph n) | Uses the ParseDot instance for generalised `DotGraph`s.

parseIt :: ParseDot a => Text -> (a, Text)

Parse the required value, returning also the rest of the input `Text` that hasn't been parsed (for debugging purposes).

parseIt' :: ParseDot a => Text -> a

Parse the required value with the assumption that it will parse all of the input `Text`.

runParser :: Parse a -> Text -> (Either String a, Text)

runParser' :: Parse a -> Text -> a

A variant of `runParser` where it is assumed that the provided parsing function consumes all of the `Text` input (with the exception of whitespace at the end).

runParserWith :: (GraphvizState -> GraphvizState) -> Parse a -> Text -> (Either String a, Text)

parseLiberally :: GraphvizState -> GraphvizState

checkValidParse :: Either String a -> a

If unable to parse Dot code properly, `throw` a `GraphvizException`.

# Convenience parsing combinators.

ignoreSep :: (a -> b -> c) -> Parse a -> Parse sep -> Parse b -> Parse c

The opposite of `bracket`.

onlyBool :: Parse Bool

Use this when you do not want numbers to be treated as `Bool` values.

quotelessString :: Parse Text

Parse a `Text` that doesn't need to be quoted.

stringBlock :: Parse Text

numString :: Bool -> Parse Text

isNumString :: Text -> Bool

Determine if this String represents a number.

isIntString :: Text -> Bool

quotedString :: Parse Text

Used when quotes are explicitly required;

parseEscaped :: Bool -> [Char] -> [Char] -> Parse Text

Parse a `Text` where the provided `Char`s (as well as `"` and `\`) are escaped and the second list of `Char`s are those that are not permitted. Note: does not parse surrounding quotes. The `Bool` value indicates whether empty `Text`s are allowed or not.

parseAndSpace :: Parse a -> Parse a

string :: String -> Parse ()

strings :: [String] -> Parse ()

character :: Char -> Parse Char

Assumes that any letter is ASCII for case-insensitive comparisons.

parseStrictFloat :: Bool -> Parse Double

Parse a floating point number that actually contains decimals. Bool flag indicates whether values that need to be quoted are parsed.

parseSignedFloat :: Bool -> Parse Double

noneOf :: [Char] -> Parse Char

whitespace1 :: Parse ()

Parses at least one whitespace character.

whitespace :: Parse ()

Parses zero or more whitespace characters.

wrapWhitespace :: Parse a -> Parse a

Parse and discard optional surrounding whitespace.

optionalQuotedString :: String -> Parse ()

optionalQuoted :: Parse a -> Parse a

quotedParse :: Parse a -> Parse a

orQuote :: Parse Char -> Parse Char

quoteChar :: Char

newline :: Parse ()

Parses a newline.

newline' :: Parse ()

Consume all whitespace and newlines until a line with non-whitespace is reached. The whitespace on that line is not consumed.

parseComma :: Parse ()

parseEq :: Parse ()

tryParseList :: ParseDot a => Parse [a]

Try to parse a list of the specified type; returns an empty list if parsing fails.

tryParseList' :: Parse [a] -> Parse [a]

Return an empty list if parsing a list fails.

consumeLine :: Parse Text

Parses and returns all characters up till the end of the line, but does not touch the newline characters.

commaSep :: (ParseDot a, ParseDot b) => Parse (a, b)

commaSepUnqt :: (ParseDot a, ParseDot b) => Parse (a, b)

commaSep' :: Parse a -> Parse b -> Parse (a, b)

stringRep :: a -> String -> Parse a

stringReps :: a -> [String] -> Parse a

stringParse :: [(String, Parse a)] -> Parse a

stringValue :: [(String, a)] -> Parse a

parseAngled :: Parse a -> Parse a

parseBraced :: Parse a -> Parse a

parseColorScheme :: Bool -> Parse ColorScheme