graph/formats/dot: rename Kind* => *Kind
MODIFY
graph/encoding/dot/decode.go
graph/encoding/dot/decode.go
@@ -140,19 +140,19 @@ func (gen *generator) addStmt(dst Builder, stmt ast.Stmt) {
var n UnmarshalerAttr
var dst string
switch stmt.Kind {
- case ast.KindGraph:
+ case ast.GraphKind:
if gen.graphAttr == nil {
return
}
n = gen.graphAttr
dst = "graph"
- case ast.KindNode:
+ case ast.NodeKind:
if gen.nodeAttr == nil {
return
}
n = gen.nodeAttr
dst = "node"
- case ast.KindEdge:
+ case ast.EdgeKind:
if gen.edgeAttr == nil {
return
}

MODIFY
graph/formats/dot/ast/ast.go
graph/formats/dot/ast/ast.go
@@ -228,22 +228,22 @@ type Kind uint
// Graph component kinds.
const (
- KindGraph Kind = iota // graph
- KindNode // node
- KindEdge // edge
+ GraphKind Kind = iota // graph
+ NodeKind // node
+ EdgeKind // edge
)
// String returns the string representation of the graph component kind.
func (k Kind) String() string {
switch k {
- case KindGraph:
+ case GraphKind:
return "graph"
- case KindNode:
+ case NodeKind:
return "node"
- case KindEdge:
+ case EdgeKind:
return "edge"
}
- panic(fmt.Sprintf("invalid graph component kind (%d)", uint(k)))
+ panic(fmt.Sprintf("invalid graph component kind (%d)", k))
}
// --- [ Attribute ] -----------------------------------------------------------

MODIFY
graph/formats/dot/internal/dot.bnf
graph/formats/dot/internal/dot.bnf
@@ -254,9 +254,9 @@ AttrStmt
;
Component
- : graphx << ast.KindGraph, nil >>
- | node << ast.KindNode, nil >>
- | edge << ast.KindEdge, nil >>
+ : graphx << ast.GraphKind, nil >>
+ | node << ast.NodeKind, nil >>
+ | edge << ast.EdgeKind, nil >>
;
// AttrList : "[" [ AList ] "]" [ AttrList ]

MODIFY
graph/formats/dot/internal/parser/productionstable.go
graph/formats/dot/internal/parser/productionstable.go
@@ -304,33 +304,33 @@ var productionsTable = ProdTab{
},
},
ProdTabEntry{
- String: `Component : graphx << ast.KindGraph, nil >>`,
+ String: `Component : graphx << ast.GraphKind, nil >>`,
Id: "Component",
NTType: 15,
Index: 27,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
- return ast.KindGraph, nil
+ return ast.GraphKind, nil
},
},
ProdTabEntry{
- String: `Component : node << ast.KindNode, nil >>`,
+ String: `Component : node << ast.NodeKind, nil >>`,
Id: "Component",
NTType: 15,
Index: 28,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
- return ast.KindNode, nil
+ return ast.NodeKind, nil
},
},
ProdTabEntry{
- String: `Component : edge << ast.KindEdge, nil >>`,
+ String: `Component : edge << ast.EdgeKind, nil >>`,
Id: "Component",
NTType: 15,
Index: 29,
NumSymbols: 1,
ReduceFunc: func(X []Attrib) (Attrib, error) {
- return ast.KindEdge, nil
+ return ast.EdgeKind, nil
},
},
ProdTabEntry{

MODIFY
graph/formats/dot/sem.go
graph/formats/dot/sem.go
@@ -48,7 +48,7 @@ func checkStmt(graph *ast.Graph, stmt ast.Stmt) error {
return checkAttrStmt(graph, stmt)
case *ast.Attr:
// TODO: Verify that the attribute is indeed of graph component kind.
- return checkAttr(graph, ast.KindGraph, stmt)
+ return checkAttr(graph, ast.GraphKind, stmt)
case *ast.Subgraph:
return checkSubgraph(graph, stmt)
default:
@@ -63,7 +63,7 @@ func checkNodeStmt(graph *ast.Graph, stmt *ast.NodeStmt) error {
}
for _, attr := range stmt.Attrs {
// TODO: Verify that the attribute is indeed of node component kind.
- if err := checkAttr(graph, ast.KindNode, attr); err != nil {
+ if err := checkAttr(graph, ast.NodeKind, attr); err != nil {
return err
}
}
@@ -78,7 +78,7 @@ func checkEdgeStmt(graph *ast.Graph, stmt *ast.EdgeStmt) error {
}
for _, attr := range stmt.Attrs {
// TODO: Verify that the attribute is indeed of edge component kind.
- if err := checkAttr(graph, ast.KindEdge, attr); err != nil {
+ if err := checkAttr(graph, ast.EdgeKind, attr); err != nil {
return err
}
}
@@ -113,13 +113,13 @@ func checkAttrStmt(graph *ast.Graph, stmt *ast.AttrStmt) error {
// component kind.
func checkAttr(graph *ast.Graph, kind ast.Kind, attr *ast.Attr) error {
switch kind {
- case ast.KindGraph:
+ case ast.GraphKind:
// TODO: Validate key-value pairs for graphs.
return nil
- case ast.KindNode:
+ case ast.NodeKind:
// TODO: Validate key-value pairs for nodes.
return nil
- case ast.KindEdge:
+ case ast.EdgeKind:
// TODO: Validate key-value pairs for edges.
return nil
default:

graph/formats/dot: rename Kind* => *Kind