summaryrefslogtreecommitdiff
path: root/Haskell-book/24/language-dot/src/Language/Dot/Syntax.hs
blob: cca7d9961ed3163cdad9bb3bf4afa7e067689e05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
-- | DOT AST. See <http://www.graphviz.org/doc/info/lang.html>.

module Language.Dot.Syntax where

data Graph
  = Graph GraphStrictness GraphDirectedness (Maybe Id) [Statement]
  deriving (Eq, Show)

data GraphStrictness
  = StrictGraph
  | UnstrictGraph
  deriving (Eq, Show)

data GraphDirectedness
  = DirectedGraph
  | UndirectedGraph
  deriving (Eq, Show)

data Id
  = NameId    String
  | StringId  String
  | IntegerId Integer
  | FloatId   Float
  | XmlId     Xml
  deriving (Eq, Show)

data Statement
  = NodeStatement       NodeId [Attribute]
  | EdgeStatement       [Entity] [Attribute]
  | AttributeStatement  AttributeStatementType [Attribute]
  | AssignmentStatement Id Id
  | SubgraphStatement   Subgraph
  deriving (Eq, Show)

data AttributeStatementType
  = GraphAttributeStatement
  | NodeAttributeStatement
  | EdgeAttributeStatement
  deriving (Eq, Show)

data Attribute
  = AttributeSetTrue  Id
  | AttributeSetValue Id Id
  deriving (Eq, Show)

data NodeId
  = NodeId Id (Maybe Port)
  deriving (Eq, Show)

data Port
  = PortI Id (Maybe Compass)
  | PortC Compass
  deriving (Eq, Show)

data Compass
  = CompassN  | CompassE  | CompassS  | CompassW
  | CompassNE | CompassNW | CompassSE | CompassSW
  deriving (Eq, Show)

data Subgraph
  = NewSubgraph (Maybe Id) [Statement]
  | SubgraphRef Id
  deriving (Eq, Show)

data Entity
  = ENodeId   EdgeType NodeId
  | ESubgraph EdgeType Subgraph
  deriving (Eq, Show)

data EdgeType
  = NoEdge
  | DirectedEdge
  | UndirectedEdge
  deriving (Eq, Show)

data Xml
  = XmlEmptyTag XmlName [XmlAttribute]
  | XmlTag      XmlName [XmlAttribute] [Xml]
  | XmlText     String
  deriving (Eq, Show)

data XmlName
  = XmlName String
  deriving (Eq, Show)

data XmlAttribute
  = XmlAttribute XmlName XmlAttributeValue
  deriving (Eq, Show)

data XmlAttributeValue
  = XmlAttributeValue String
  deriving (Eq, Show)