Codebase list golang-github-awalterschulze-gographviz / 61bb010
Import upstream version 2.0.3+git20210715.1.148e697 Debian Janitor 2 years ago
20 changed file(s) with 514 addition(s) and 304 deletion(s). Raw diff Collapse all Expand all
0 name: build
1
2 on: [push, pull_request]
3
4 jobs:
5 build:
6 runs-on: ubuntu-latest
7 env:
8 working-directory: ./src/github.com/awalterschulze/gographviz
9
10 steps:
11 - name: Set GOPATH
12 run: |
13 echo "GOPATH=$(dirname $GITHUB_WORKSPACE)/gographviz" >> $GITHUB_ENV
14 echo "$(dirname $GITHUB_WORKSPACE)/gographviz/bin" >> $GITHUB_PATH
15 shell: bash
16
17 - name: Setup Go
18 uses: actions/setup-go@v2
19 with:
20 go-version: '1.14'
21
22 - name: Checkout
23 uses: actions/checkout@v2
24 with:
25 fetch-depth: 1
26 path: src/github.com/awalterschulze/gographviz
27
28 - name: Install dependencies
29 run: make dependencies
30 working-directory: ${{env.working-directory}}
31
32 - name: Run regenerate
33 run: make regenerate
34 working-directory: ${{env.working-directory}}
35
36 - name: Run build
37 run: make build
38 working-directory: ${{env.working-directory}}
39
40 - name: Run checkers
41 run: make checkers
42 working-directory: ${{env.working-directory}}
43
44 - name: Run testing
45 run: make test
46 working-directory: ${{env.working-directory}}
+0
-10
.travis.yml less more
0 before_install:
1 - ./install-godeps.sh
2
3 script:
4 - make travis
5
6 language: go
7
8 go:
9 - 1.x
0 regenerate:
0 .PHONY: help regenerate test dependencies build checkers action
1
2 # Prefer tools that we've installed
3 export PATH := $(HOME)/go/bin:$(PATH)
4
5 help:
6 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
7
8 regenerate: ## Re-generate lexers and parsers and pass through goimports
9 go get github.com/goccmack/gocc
110 go install github.com/goccmack/gocc
2 gocc -zip -o ./internal/ dot.bnf
11 gocc -zip -o ./internal/ dot.bnf
312 find . -type f -name '*.go' | xargs goimports -w
413
5 test:
14 test: ## Perform package tests
615 go test ./...
716
8 travis:
9 make regenerate
10 go build ./...
11 go test ./...
17 dependencies: ## Grab necessary dependencies for checkers
18 go version
19 go get golang.org/x/tools/cmd/goimports
20 go get github.com/kisielk/errcheck
21 go get -u golang.org/x/lint/golint
22
23 build: ## Perform build process
24 go build .
25
26 checkers: ## Run all checkers (errcheck, gofmt and golint)
1227 errcheck -ignore 'fmt:[FS]?[Pp]rint*' ./...
1328 gofmt -l -s -w .
1429 golint -set_exit_status
1530 git diff --exit-code
31
32 action: dependencies regenerate build test checkers ## Run steps of github action
1717
1818 ### Documentation ###
1919
20 The [godoc](https://godoc.org/github.com/awalterschulze/gographviz) includes some more examples.
20 - The [godoc](https://godoc.org/github.com/awalterschulze/gographviz) includes some more examples.
21 - [How to implement an anonymous subgraph](https://github.com/awalterschulze/gographviz/issues/59)
2122
2223 ### Installation ###
2324 go get github.com/awalterschulze/gographviz
2425
25 ### Tests ###
26 ### Build and Tests ###
2627
27 [![Build Status](https://travis-ci.org/awalterschulze/gographviz.svg?branch=master)](https://travis-ci.org/awalterschulze/gographviz)
28 [![Build Status](https://github.com/awalterschulze/gographviz/workflows/build/badge.svg)](https://github.com/awalterschulze/gographviz/actions)
29
2830
2931 ### Users ###
3032
3335 - [imagemonkey](https://imagemonkey.io/graph?editor=true) - Let's create our own image dataset
3436 - [depviz](https://github.com/moul/depviz) - GitHub dependency visualizer (auto-roadmap)
3537 - [kustomize-graph](https://github.com/jpreese/kustomize-graph) - A tool to visualize Kustomize dependencies
38 - [inframap](https://github.com/cycloidio/inframap) - Read your tfstate or HCL to generate a graph specific for each Terraform provider
39 - [Antrea Traceflow](https://github.com/vmware-tanzu/antrea/blob/master/docs/traceflow-guide.md) supports using Traceflow for network diagnosis for Antrea, a Kubernetes networking solution intended to be Kubernetes native
3640
3741 ### Mentions ###
3842
103103 func TestString(t *testing.T) {
104104 anal(t,
105105 `digraph finite_state { rankdir = "LR" }`)
106 }
107
108 func TestAttrImgPos(t *testing.T) {
109 anal(t,
110 "digraph finite_state { imagepos = tc }")
106111 }
107112
108113 func TestAttrList(t *testing.T) {
111111 }
112112 s += this.Type.String() + " " + this.ID.String() + " {\n"
113113 if this.StmtList != nil {
114 s += this.StmtList.String()
114 s += this.StmtList.indentString("\t")
115115 }
116116 s += "\n}\n"
117117 return s
142142 }
143143
144144 func (this StmtList) String() string {
145 return this.indentString("")
146 }
147
148 func (this StmtList) indentString(indent string) string {
145149 if len(this) == 0 {
146150 return ""
147151 }
148152 s := ""
149153 for i := 0; i < len(this); i++ {
150 ss := this[i].String()
154 ss := this[i].indentString(indent)
151155 if len(ss) > 0 {
152 s += "\t" + ss + ";\n"
156 s += ss + ";\n"
153157 }
154158 }
159 s = strings.TrimSuffix(s, "\n")
155160 return s
156161 }
157162
169174 Elem
170175 Walkable
171176 isStmt()
177 indentString(string) string
172178 }
173179
174180 func (this NodeStmt) isStmt() {}
215221 }
216222
217223 func (this *SubGraph) String() string {
224 return this.indentString("")
225 }
226
227 func (this *SubGraph) indentString(indent string) string {
218228 gName := this.ID.String()
219229 if strings.HasPrefix(gName, "anon") {
220230 gName = ""
221231 }
222 s := "subgraph " + this.ID.String() + " {\n"
232
233 s := indent + "subgraph " + this.ID.String() + " {\n"
223234 if this.StmtList != nil {
224 s += this.StmtList.String()
225 }
226 s += "\n}\n"
235 s += this.StmtList.indentString(indent + "\t")
236 }
237 s += "\n" + indent + "}"
227238 return s
228239 }
229240
243254 }
244255
245256 func (this EdgeAttrs) String() string {
257 return this.indentString("")
258 }
259
260 func (this EdgeAttrs) indentString(indent string) string {
246261 s := AttrList(this).String()
247262 if len(s) == 0 {
248263 return ""
249264 }
250 return `edge ` + s
265 return indent + `edge ` + s
251266 }
252267
253268 func (this EdgeAttrs) Walk(v Visitor) {
267282 }
268283
269284 func (this NodeAttrs) String() string {
285 return this.indentString("")
286 }
287
288 func (this NodeAttrs) indentString(indent string) string {
270289 s := AttrList(this).String()
271290 if len(s) == 0 {
272291 return ""
273292 }
274 return `node ` + s
293 return indent + `node ` + s
275294 }
276295
277296 func (this NodeAttrs) Walk(v Visitor) {
291310 }
292311
293312 func (this GraphAttrs) String() string {
313 return this.indentString("")
314 }
315
316 func (this GraphAttrs) indentString(indent string) string {
294317 s := AttrList(this).String()
295318 if len(s) == 0 {
296319 return ""
297320 }
298 return `graph ` + s
321 return indent + `graph ` + s
299322 }
300323
301324 func (this GraphAttrs) Walk(v Visitor) {
428451 }
429452
430453 func (this *Attr) String() string {
431 return this.Field.String() + `=` + this.Value.String()
454 return this.indentString("")
455 }
456
457 func (this *Attr) indentString(indent string) string {
458 return indent + this.Field.String() + `=` + this.Value.String()
432459 }
433460
434461 func (this *Attr) Walk(v Visitor) {
475502 }
476503
477504 func (this EdgeStmt) String() string {
478 return strings.TrimSpace(this.Source.String() + this.EdgeRHS.String() + this.Attrs.String())
505 return this.indentString("")
506 }
507
508 func (this EdgeStmt) indentString(indent string) string {
509 return indent + strings.TrimSpace(this.Source.String()+this.EdgeRHS.String()+` `+this.Attrs.String())
479510 }
480511
481512 func (this EdgeStmt) Walk(v Visitor) {
557588 }
558589
559590 func (this NodeStmt) String() string {
560 return strings.TrimSpace(this.NodeID.String() + ` ` + this.Attrs.String())
591 return this.indentString("")
592 }
593
594 func (this NodeStmt) indentString(indent string) string {
595 return indent + strings.TrimSpace(this.NodeID.String()+` `+this.Attrs.String())
561596 }
562597
563598 func (this NodeStmt) Walk(v Visitor) {
140140 Image Attr = "image"
141141 // ImagePath http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:imagepath
142142 ImagePath Attr = "imagepath"
143 // ImagePos https://graphviz.org/doc/info/attrs.html#d:imagepos
144 ImagePos Attr = "imagepos"
143145 // ImageScale http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:imagescale
144146 ImageScale Attr = "imagescale"
145147 // InputScale http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:inputscale
436438 string(ID): ID,
437439 string(Image): Image,
438440 string(ImagePath): ImagePath,
441 string(ImagePos): ImagePos,
439442 string(ImageScale): ImageScale,
440443 string(InputScale): InputScale,
441444 string(Label): Label,
7575 return false
7676 }
7777 if c == '/' {
78 return false
79 }
80 if c == '.' {
7881 return false
7982 }
8083 i++
4545 if err := g.AddNode("asdf asdf", "a/b", nil); err != nil {
4646 t.Fatal(err)
4747 }
48 if err := g.AddNode("asdf asdf", "c.d", nil); err != nil {
49 t.Fatal(err)
50 }
51 if err := g.AddNode("asdf asdf", "e-f", nil); err != nil {
52 t.Fatal(err)
53 }
54 if err := g.AddNode("asdf asdf", "12_34", nil); err != nil {
55 t.Fatal(err)
56 }
4857 s := g.String()
4958 if !strings.HasPrefix(s, `digraph "asdf adsf" {
5059 "kasdf99 99"->7;
60 "12_34";
5161 "a &lt;&lt; b";
5262 "a/b";
63 "c.d";
64 "e-f";
5365 "kasdf99 99" [ URL="<a" ];
5466 7 [ URL="<a" ];
55
5667 }`) {
5768 t.Fatalf("%s", s)
5869 }
8899 graphStr := `graph G {
89100 cluster_2--cluster_1;
90101 subgraph cluster0 {
91 subgraph cluster_1 {
102 subgraph cluster_1 {
92103
93 }
94 ;
95 subgraph cluster_2 {
104 };
105 subgraph cluster_2 {
96106
97 }
98 ;
99
100 }
101 ;
107 };
108 };
102109 "Code deployment";
103
104110 }`
105111 if !strings.HasPrefix(s, graphStr) {
106112 t.Fatalf("%s", s)
2929 // Hello->World;
3030 // Hello;
3131 // World;
32 //
3332 //}
3433 }
3534
5655 // Hello->World;
5756 // Hello;
5857 // World;
59 //
6058 //}
6159 }
6260
159157 s := output.String()
160158 fmt.Println(s)
161159 // Output: digraph matrix {
162 // 1->1[ label=0 ];
163 // 1->2[ label=5 ];
164 // 1->3[ label=0 ];
165 // 1->4[ label=0 ];
166 // 2->1[ label=0 ];
167 // 2->2[ label=0 ];
168 // 2->3[ label=0 ];
169 // 2->4[ label=0 ];
170 // 3->1[ label=0 ];
171 // 3->2[ label=0 ];
172 // 3->3[ label=0 ];
173 // 3->4[ label=0 ];
174 // 4->1[ label=2 ];
175 // 4->2[ label=1 ];
176 // 4->3[ label=0 ];
177 // 4->4[ label=0 ];
160 // 1->1 [ label=0 ];
161 // 1->2 [ label=5 ];
162 // 1->3 [ label=0 ];
163 // 1->4 [ label=0 ];
164 // 2->1 [ label=0 ];
165 // 2->2 [ label=0 ];
166 // 2->3 [ label=0 ];
167 // 2->4 [ label=0 ];
168 // 3->1 [ label=0 ];
169 // 3->2 [ label=0 ];
170 // 3->3 [ label=0 ];
171 // 3->4 [ label=0 ];
172 // 4->1 [ label=2 ];
173 // 4->2 [ label=1 ];
174 // 4->3 [ label=0 ];
175 // 4->4 [ label=0 ];
178176 // 1;
179177 // 2;
180178 // 3;
181179 // 4;
182 //
183180 //}
184181 }
+0
-7
install-godeps.sh less more
0 #!/usr/bin/env bash
1 set -xe
2 mkdir -p $GOPATH/src/githbub.com/goccmack
3 git clone https://github.com/goccmack/gocc $GOPATH/src/github.com/goccmack/gocc
4 go get golang.org/x/tools/cmd/goimports
5 go get github.com/kisielk/errcheck
6 go get -u golang.org/x/lint/golint
33
44 import (
55 "fmt"
6 "strconv"
67 "strings"
8 "unicode"
79
810 "github.com/awalterschulze/gographviz/internal/token"
911 )
2123
2224 func (e *Error) String() string {
2325 w := new(strings.Builder)
24 fmt.Fprintf(w, "Error")
2526 if e.Err != nil {
26 fmt.Fprintf(w, " %s\n", e.Err)
27 fmt.Fprintln(w, "Error ", e.Err)
2728 } else {
28 fmt.Fprintf(w, "\n")
29 fmt.Fprintln(w, "Error")
2930 }
3031 fmt.Fprintf(w, "Token: type=%d, lit=%s\n", e.ErrorToken.Type, e.ErrorToken.Lit)
3132 fmt.Fprintf(w, "Pos: offset=%d, line=%d, column=%d\n", e.ErrorToken.Pos.Offset, e.ErrorToken.Pos.Line, e.ErrorToken.Pos.Column)
32 fmt.Fprintf(w, "Expected one of: ")
33 fmt.Fprint(w, "Expected one of: ")
3334 for _, sym := range e.ExpectedTokens {
34 fmt.Fprintf(w, "%s ", sym)
35 fmt.Fprint(w, string(sym), " ")
3536 }
36 fmt.Fprintf(w, "ErrorSymbol:\n")
37 fmt.Fprintln(w, "ErrorSymbol:")
3738 for _, sym := range e.ErrorSymbols {
3839 fmt.Fprintf(w, "%v\n", sym)
3940 }
41
4042 return w.String()
4143 }
4244
45 func DescribeExpected(tokens []string) string {
46 switch len(tokens) {
47 case 0:
48 return "unexpected additional tokens"
49
50 case 1:
51 return "expected " + tokens[0]
52
53 case 2:
54 return "expected either " + tokens[0] + " or " + tokens[1]
55
56 case 3:
57 // Oxford-comma rules require more than 3 items in a list for the
58 // comma to appear before the 'or'
59 return fmt.Sprintf("expected one of %s, %s or %s", tokens[0], tokens[1], tokens[2])
60
61 default:
62 // Oxford-comma separated alternatives list.
63 tokens = append(tokens[:len(tokens)-1], "or "+tokens[len(tokens)-1])
64 return "expected one of " + strings.Join(tokens, ", ")
65 }
66 }
67
68 func DescribeToken(tok *token.Token) string {
69 switch tok.Type {
70 case token.INVALID:
71 return fmt.Sprintf("unknown/invalid token %q", tok.Lit)
72 case token.EOF:
73 return "end-of-file"
74 default:
75 return fmt.Sprintf("%q", tok.Lit)
76 }
77 }
78
4379 func (e *Error) Error() string {
44 w := new(strings.Builder)
45 fmt.Fprintf(w, "Error in S%d: %s, %s", e.StackTop, token.TokMap.TokenString(e.ErrorToken), e.ErrorToken.Pos.String())
80 // identify the line and column of the error in 'gnu' style so it can be understood
81 // by editors and IDEs; user will need to prefix it with a filename.
82 text := fmt.Sprintf("%d:%d: error: ", e.ErrorToken.Pos.Line, e.ErrorToken.Pos.Column)
83
84 // See if the error token can provide us with the filename.
85 switch src := e.ErrorToken.Pos.Context.(type) {
86 case token.Sourcer:
87 text = src.Source() + ":" + text
88 }
89
4690 if e.Err != nil {
47 fmt.Fprintf(w, ": %+v", e.Err)
91 // Custom error specified, e.g. by << nil, errors.New("missing newline") >>
92 text += e.Err.Error()
4893 } else {
49 fmt.Fprintf(w, ", expected one of: ")
50 for _, expected := range e.ExpectedTokens {
51 fmt.Fprintf(w, "%s ", expected)
94 tokens := make([]string, len(e.ExpectedTokens))
95 for idx, token := range e.ExpectedTokens {
96 if !unicode.IsLetter(rune(token[0])) {
97 token = strconv.Quote(token)
98 }
99 tokens[idx] = token
52100 }
101 text += DescribeExpected(tokens)
102 actual := DescribeToken(e.ErrorToken)
103 text += fmt.Sprintf("; got: %s", actual)
53104 }
54 return w.String()
105
106 return text
55107 }
1515 )
1616
1717 type Lexer struct {
18 src []byte
19 pos int
20 line int
21 column int
18 src []byte
19 pos int
20 line int
21 column int
22 Context token.Context
2223 }
2324
2425 func NewLexer(src []byte) *Lexer {
2526 lexer := &Lexer{
26 src: src,
27 pos: 0,
28 line: 1,
29 column: 1,
27 src: src,
28 pos: 0,
29 line: 1,
30 column: 1,
31 Context: nil,
3032 }
3133 return lexer
34 }
35
36 // SourceContext is a simple instance of a token.Context which
37 // contains the name of the source file.
38 type SourceContext struct {
39 Filepath string
40 }
41
42 func (s *SourceContext) Source() string {
43 return s.Filepath
3244 }
3345
3446 func NewLexerFile(fpath string) (*Lexer, error) {
3648 if err != nil {
3749 return nil, err
3850 }
39 return NewLexer(src), nil
51 lexer := NewLexer(src)
52 lexer.Context = &SourceContext{Filepath: fpath}
53 return lexer, nil
4054 }
4155
4256 func (l *Lexer) Scan() (tok *token.Token) {
43 tok = new(token.Token)
57 tok = &token.Token{}
4458 if l.pos >= len(l.src) {
4559 tok.Type = token.EOF
4660 tok.Pos.Offset, tok.Pos.Line, tok.Pos.Column = l.pos, l.line, l.column
61 tok.Pos.Context = l.Context
4762 return
4863 }
4964 start, startLine, startColumn, end := l.pos, l.line, l.column, 0
102117 tok.Lit = []byte{}
103118 }
104119 tok.Pos.Offset, tok.Pos.Line, tok.Pos.Column = start, startLine, startColumn
120 tok.Pos.Context = l.Context
105121
106122 return
107123 }
0 // Code generated by gocc; DO NOT EDIT.
1
2 package parser
3
4 // Parser-specific user-defined and entirely-optional context,
5 // accessible as '$Context' in SDT actions.
6 type Context interface{}
9090 stack *stack
9191 nextToken *token.Token
9292 pos int
93 Context Context
9394 }
9495
9596 type Scanner interface {
201202 p.nextToken = scanner.Scan()
202203 case reduce:
203204 prod := productionsTable[int(act)]
204 attrib, err := prod.ReduceFunc(p.stack.popN(prod.NumSymbols))
205 attrib, err := prod.ReduceFunc(p.stack.popN(prod.NumSymbols), p.Context)
205206 if err != nil {
206207 return nil, p.newError(err)
207208 } else {
44 import "github.com/awalterschulze/gographviz/ast"
55
66 type (
7 //TODO: change type and variable names to be consistent with other tables
87 ProdTab [numProductions]ProdTabEntry
98 ProdTabEntry struct {
109 String string
1211 NTType int
1312 Index int
1413 NumSymbols int
15 ReduceFunc func([]Attrib) (Attrib, error)
14 ReduceFunc func([]Attrib, interface{}) (Attrib, error)
1615 }
1716 Attrib interface {
1817 }
2524 NTType: 0,
2625 Index: 0,
2726 NumSymbols: 1,
28 ReduceFunc: func(X []Attrib) (Attrib, error) {
27 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
2928 return X[0], nil
3029 },
3130 },
3534 NTType: 1,
3635 Index: 1,
3736 NumSymbols: 3,
38 ReduceFunc: func(X []Attrib) (Attrib, error) {
37 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
3938 return ast.NewGraph(ast.GRAPH, ast.FALSE, nil, nil)
4039 },
4140 },
4544 NTType: 1,
4645 Index: 2,
4746 NumSymbols: 4,
48 ReduceFunc: func(X []Attrib) (Attrib, error) {
47 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
4948 return ast.NewGraph(ast.GRAPH, ast.TRUE, nil, nil)
5049 },
5150 },
5554 NTType: 1,
5655 Index: 3,
5756 NumSymbols: 4,
58 ReduceFunc: func(X []Attrib) (Attrib, error) {
57 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
5958 return ast.NewGraph(ast.GRAPH, ast.FALSE, X[1], nil)
6059 },
6160 },
6564 NTType: 1,
6665 Index: 4,
6766 NumSymbols: 5,
68 ReduceFunc: func(X []Attrib) (Attrib, error) {
67 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
6968 return ast.NewGraph(ast.GRAPH, ast.TRUE, X[2], nil)
7069 },
7170 },
7574 NTType: 1,
7675 Index: 5,
7776 NumSymbols: 4,
78 ReduceFunc: func(X []Attrib) (Attrib, error) {
77 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
7978 return ast.NewGraph(ast.GRAPH, ast.FALSE, nil, X[2])
8079 },
8180 },
8584 NTType: 1,
8685 Index: 6,
8786 NumSymbols: 5,
88 ReduceFunc: func(X []Attrib) (Attrib, error) {
87 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
8988 return ast.NewGraph(ast.GRAPH, ast.FALSE, X[1], X[3])
9089 },
9190 },
9594 NTType: 1,
9695 Index: 7,
9796 NumSymbols: 5,
98 ReduceFunc: func(X []Attrib) (Attrib, error) {
97 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
9998 return ast.NewGraph(ast.GRAPH, ast.TRUE, nil, X[3])
10099 },
101100 },
105104 NTType: 1,
106105 Index: 8,
107106 NumSymbols: 6,
108 ReduceFunc: func(X []Attrib) (Attrib, error) {
107 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
109108 return ast.NewGraph(ast.GRAPH, ast.TRUE, X[2], X[4])
110109 },
111110 },
115114 NTType: 1,
116115 Index: 9,
117116 NumSymbols: 3,
118 ReduceFunc: func(X []Attrib) (Attrib, error) {
117 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
119118 return ast.NewGraph(ast.DIGRAPH, ast.FALSE, nil, nil)
120119 },
121120 },
125124 NTType: 1,
126125 Index: 10,
127126 NumSymbols: 4,
128 ReduceFunc: func(X []Attrib) (Attrib, error) {
127 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
129128 return ast.NewGraph(ast.DIGRAPH, ast.TRUE, nil, nil)
130129 },
131130 },
135134 NTType: 1,
136135 Index: 11,
137136 NumSymbols: 4,
138 ReduceFunc: func(X []Attrib) (Attrib, error) {
137 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
139138 return ast.NewGraph(ast.DIGRAPH, ast.FALSE, X[1], nil)
140139 },
141140 },
145144 NTType: 1,
146145 Index: 12,
147146 NumSymbols: 5,
148 ReduceFunc: func(X []Attrib) (Attrib, error) {
147 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
149148 return ast.NewGraph(ast.DIGRAPH, ast.TRUE, X[2], nil)
150149 },
151150 },
155154 NTType: 1,
156155 Index: 13,
157156 NumSymbols: 4,
158 ReduceFunc: func(X []Attrib) (Attrib, error) {
157 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
159158 return ast.NewGraph(ast.DIGRAPH, ast.FALSE, nil, X[2])
160159 },
161160 },
165164 NTType: 1,
166165 Index: 14,
167166 NumSymbols: 5,
168 ReduceFunc: func(X []Attrib) (Attrib, error) {
167 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
169168 return ast.NewGraph(ast.DIGRAPH, ast.FALSE, X[1], X[3])
170169 },
171170 },
175174 NTType: 1,
176175 Index: 15,
177176 NumSymbols: 5,
178 ReduceFunc: func(X []Attrib) (Attrib, error) {
177 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
179178 return ast.NewGraph(ast.DIGRAPH, ast.TRUE, nil, X[3])
180179 },
181180 },
185184 NTType: 1,
186185 Index: 16,
187186 NumSymbols: 6,
188 ReduceFunc: func(X []Attrib) (Attrib, error) {
187 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
189188 return ast.NewGraph(ast.DIGRAPH, ast.TRUE, X[2], X[4])
190189 },
191190 },
195194 NTType: 2,
196195 Index: 17,
197196 NumSymbols: 1,
198 ReduceFunc: func(X []Attrib) (Attrib, error) {
197 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
199198 return ast.NewStmtList(X[0])
200199 },
201200 },
205204 NTType: 2,
206205 Index: 18,
207206 NumSymbols: 2,
208 ReduceFunc: func(X []Attrib) (Attrib, error) {
207 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
209208 return ast.AppendStmtList(X[0], X[1])
210209 },
211210 },
215214 NTType: 3,
216215 Index: 19,
217216 NumSymbols: 1,
218 ReduceFunc: func(X []Attrib) (Attrib, error) {
217 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
219218 return X[0], nil
220219 },
221220 },
225224 NTType: 3,
226225 Index: 20,
227226 NumSymbols: 2,
228 ReduceFunc: func(X []Attrib) (Attrib, error) {
227 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
229228 return X[0], nil
230229 },
231230 },
235234 NTType: 4,
236235 Index: 21,
237236 NumSymbols: 3,
238 ReduceFunc: func(X []Attrib) (Attrib, error) {
237 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
239238 return ast.NewAttr(X[0], X[2])
240239 },
241240 },
245244 NTType: 4,
246245 Index: 22,
247246 NumSymbols: 1,
248 ReduceFunc: func(X []Attrib) (Attrib, error) {
247 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
249248 return X[0], nil
250249 },
251250 },
255254 NTType: 4,
256255 Index: 23,
257256 NumSymbols: 1,
258 ReduceFunc: func(X []Attrib) (Attrib, error) {
257 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
259258 return X[0], nil
260259 },
261260 },
265264 NTType: 4,
266265 Index: 24,
267266 NumSymbols: 1,
268 ReduceFunc: func(X []Attrib) (Attrib, error) {
267 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
269268 return X[0], nil
270269 },
271270 },
275274 NTType: 4,
276275 Index: 25,
277276 NumSymbols: 1,
278 ReduceFunc: func(X []Attrib) (Attrib, error) {
277 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
279278 return X[0], nil
280279 },
281280 },
285284 NTType: 5,
286285 Index: 26,
287286 NumSymbols: 2,
288 ReduceFunc: func(X []Attrib) (Attrib, error) {
287 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
289288 return ast.NewGraphAttrs(X[1])
290289 },
291290 },
295294 NTType: 5,
296295 Index: 27,
297296 NumSymbols: 2,
298 ReduceFunc: func(X []Attrib) (Attrib, error) {
297 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
299298 return ast.NewNodeAttrs(X[1])
300299 },
301300 },
305304 NTType: 5,
306305 Index: 28,
307306 NumSymbols: 2,
308 ReduceFunc: func(X []Attrib) (Attrib, error) {
307 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
309308 return ast.NewEdgeAttrs(X[1])
310309 },
311310 },
315314 NTType: 6,
316315 Index: 29,
317316 NumSymbols: 2,
318 ReduceFunc: func(X []Attrib) (Attrib, error) {
317 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
319318 return ast.NewAttrList(nil)
320319 },
321320 },
325324 NTType: 6,
326325 Index: 30,
327326 NumSymbols: 3,
328 ReduceFunc: func(X []Attrib) (Attrib, error) {
327 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
329328 return ast.NewAttrList(X[1])
330329 },
331330 },
335334 NTType: 6,
336335 Index: 31,
337336 NumSymbols: 3,
338 ReduceFunc: func(X []Attrib) (Attrib, error) {
337 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
339338 return ast.AppendAttrList(X[0], nil)
340339 },
341340 },
345344 NTType: 6,
346345 Index: 32,
347346 NumSymbols: 4,
348 ReduceFunc: func(X []Attrib) (Attrib, error) {
347 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
349348 return ast.AppendAttrList(X[0], X[2])
350349 },
351350 },
355354 NTType: 7,
356355 Index: 33,
357356 NumSymbols: 1,
358 ReduceFunc: func(X []Attrib) (Attrib, error) {
357 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
359358 return ast.NewAList(X[0])
360359 },
361360 },
365364 NTType: 7,
366365 Index: 34,
367366 NumSymbols: 2,
368 ReduceFunc: func(X []Attrib) (Attrib, error) {
367 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
369368 return ast.AppendAList(X[0], X[1])
370369 },
371370 },
375374 NTType: 7,
376375 Index: 35,
377376 NumSymbols: 3,
378 ReduceFunc: func(X []Attrib) (Attrib, error) {
377 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
379378 return ast.AppendAList(X[0], X[2])
380379 },
381380 },
385384 NTType: 8,
386385 Index: 36,
387386 NumSymbols: 1,
388 ReduceFunc: func(X []Attrib) (Attrib, error) {
387 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
389388 return ast.NewAttr(X[0], nil)
390389 },
391390 },
395394 NTType: 8,
396395 Index: 37,
397396 NumSymbols: 3,
398 ReduceFunc: func(X []Attrib) (Attrib, error) {
397 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
399398 return ast.NewAttr(X[0], X[2])
400399 },
401400 },
405404 NTType: 9,
406405 Index: 38,
407406 NumSymbols: 2,
408 ReduceFunc: func(X []Attrib) (Attrib, error) {
407 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
409408 return ast.NewEdgeStmt(X[0], X[1], nil)
410409 },
411410 },
415414 NTType: 9,
416415 Index: 39,
417416 NumSymbols: 3,
418 ReduceFunc: func(X []Attrib) (Attrib, error) {
417 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
419418 return ast.NewEdgeStmt(X[0], X[1], X[2])
420419 },
421420 },
425424 NTType: 9,
426425 Index: 40,
427426 NumSymbols: 2,
428 ReduceFunc: func(X []Attrib) (Attrib, error) {
427 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
429428 return ast.NewEdgeStmt(X[0], X[1], nil)
430429 },
431430 },
435434 NTType: 9,
436435 Index: 41,
437436 NumSymbols: 3,
438 ReduceFunc: func(X []Attrib) (Attrib, error) {
437 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
439438 return ast.NewEdgeStmt(X[0], X[1], X[2])
440439 },
441440 },
445444 NTType: 10,
446445 Index: 42,
447446 NumSymbols: 2,
448 ReduceFunc: func(X []Attrib) (Attrib, error) {
447 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
449448 return ast.NewEdgeRHS(X[0], X[1])
450449 },
451450 },
455454 NTType: 10,
456455 Index: 43,
457456 NumSymbols: 2,
458 ReduceFunc: func(X []Attrib) (Attrib, error) {
457 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
459458 return ast.NewEdgeRHS(X[0], X[1])
460459 },
461460 },
465464 NTType: 10,
466465 Index: 44,
467466 NumSymbols: 3,
468 ReduceFunc: func(X []Attrib) (Attrib, error) {
467 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
469468 return ast.AppendEdgeRHS(X[0], X[1], X[2])
470469 },
471470 },
475474 NTType: 10,
476475 Index: 45,
477476 NumSymbols: 3,
478 ReduceFunc: func(X []Attrib) (Attrib, error) {
477 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
479478 return ast.AppendEdgeRHS(X[0], X[1], X[2])
480479 },
481480 },
485484 NTType: 11,
486485 Index: 46,
487486 NumSymbols: 1,
488 ReduceFunc: func(X []Attrib) (Attrib, error) {
487 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
489488 return ast.NewNodeStmt(X[0], nil)
490489 },
491490 },
495494 NTType: 11,
496495 Index: 47,
497496 NumSymbols: 2,
498 ReduceFunc: func(X []Attrib) (Attrib, error) {
497 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
499498 return ast.NewNodeStmt(X[0], X[1])
500499 },
501500 },
505504 NTType: 12,
506505 Index: 48,
507506 NumSymbols: 1,
508 ReduceFunc: func(X []Attrib) (Attrib, error) {
507 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
509508 return ast.NewNodeID(X[0], nil)
510509 },
511510 },
515514 NTType: 12,
516515 Index: 49,
517516 NumSymbols: 2,
518 ReduceFunc: func(X []Attrib) (Attrib, error) {
517 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
519518 return ast.NewNodeID(X[0], X[1])
520519 },
521520 },
525524 NTType: 13,
526525 Index: 50,
527526 NumSymbols: 2,
528 ReduceFunc: func(X []Attrib) (Attrib, error) {
527 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
529528 return ast.NewPort(X[1], nil), nil
530529 },
531530 },
535534 NTType: 13,
536535 Index: 51,
537536 NumSymbols: 4,
538 ReduceFunc: func(X []Attrib) (Attrib, error) {
537 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
539538 return ast.NewPort(X[1], X[3]), nil
540539 },
541540 },
545544 NTType: 14,
546545 Index: 52,
547546 NumSymbols: 3,
548 ReduceFunc: func(X []Attrib) (Attrib, error) {
547 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
549548 return ast.NewSubGraph(nil, X[1])
550549 },
551550 },
555554 NTType: 14,
556555 Index: 53,
557556 NumSymbols: 4,
558 ReduceFunc: func(X []Attrib) (Attrib, error) {
557 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
559558 return ast.NewSubGraph(nil, X[2])
560559 },
561560 },
565564 NTType: 14,
566565 Index: 54,
567566 NumSymbols: 5,
568 ReduceFunc: func(X []Attrib) (Attrib, error) {
567 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
569568 return ast.NewSubGraph(X[1], X[3])
570569 },
571570 },
575574 NTType: 14,
576575 Index: 55,
577576 NumSymbols: 3,
578 ReduceFunc: func(X []Attrib) (Attrib, error) {
577 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
579578 return ast.NewSubGraph(nil, nil)
580579 },
581580 },
585584 NTType: 14,
586585 Index: 56,
587586 NumSymbols: 4,
588 ReduceFunc: func(X []Attrib) (Attrib, error) {
587 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
589588 return ast.NewSubGraph(X[1], nil)
590589 },
591590 },
595594 NTType: 15,
596595 Index: 57,
597596 NumSymbols: 1,
598 ReduceFunc: func(X []Attrib) (Attrib, error) {
597 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
599598 return ast.DIRECTED, nil
600599 },
601600 },
605604 NTType: 15,
606605 Index: 58,
607606 NumSymbols: 1,
608 ReduceFunc: func(X []Attrib) (Attrib, error) {
607 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
609608 return ast.UNDIRECTED, nil
610609 },
611610 },
615614 NTType: 16,
616615 Index: 59,
617616 NumSymbols: 1,
618 ReduceFunc: func(X []Attrib) (Attrib, error) {
617 ReduceFunc: func(X []Attrib, C interface{}) (Attrib, error) {
619618 return ast.NewID(X[0])
620619 },
621620 },
0 // Code generated by gocc; DO NOT EDIT.
1
2 package token
3
4 // Context allows user-defined data to be associated with the
5 // lexer/scanner to be associated with each token that lexer
6 // produces.
7 type Context interface{}
8
9 // Sourcer is a Context interface which presents a Source() method
10 // identifying e.g the filename for the current code.
11 type Sourcer interface {
12 Source() string
13 }
22 package token
33
44 import (
5 "bytes"
56 "fmt"
7 "strconv"
8 "unicode/utf8"
69 )
710
811 type Token struct {
1922 )
2023
2124 type Pos struct {
22 Offset int
23 Line int
24 Column int
25 Offset int
26 Line int
27 Column int
28 Context Context
2529 }
2630
2731 func (p Pos) String() string {
28 return fmt.Sprintf("Pos(offset=%d, line=%d, column=%d)", p.Offset, p.Line, p.Column)
32 // If the context provides a filename, provide a human-readable File:Line:Column representation.
33 switch src := p.Context.(type) {
34 case Sourcer:
35 return fmt.Sprintf("%s:%d:%d", src.Source(), p.Line, p.Column)
36 default:
37 return fmt.Sprintf("Pos(offset=%d, line=%d, column=%d)", p.Offset, p.Line, p.Column)
38 }
2939 }
3040
3141 type TokenMap struct {
4858 }
4959
5060 func (m TokenMap) TokenString(tok *Token) string {
51 //TODO: refactor to print pos & token string properly
5261 return fmt.Sprintf("%s(%d,%s)", m.Id(tok.Type), tok.Type, tok.Lit)
5362 }
5463
5564 func (m TokenMap) StringType(typ Type) string {
5665 return fmt.Sprintf("%s(%d)", m.Id(typ), typ)
66 }
67
68 // Equals returns returns true if the token Type and Lit are matches.
69 func (t *Token) Equals(rhs interface{}) bool {
70 switch rhsT := rhs.(type) {
71 case *Token:
72 return t == rhsT || (t.Type == rhsT.Type && bytes.Equal(t.Lit, rhsT.Lit))
73 default:
74 return false
75 }
76 }
77
78 // CharLiteralValue returns the string value of the char literal.
79 func (t *Token) CharLiteralValue() string {
80 return string(t.Lit[1 : len(t.Lit)-1])
81 }
82
83 // Float32Value returns the float32 value of the token or an error if the token literal does not
84 // denote a valid float32.
85 func (t *Token) Float32Value() (float32, error) {
86 if v, err := strconv.ParseFloat(string(t.Lit), 32); err != nil {
87 return 0, err
88 } else {
89 return float32(v), nil
90 }
91 }
92
93 // Float64Value returns the float64 value of the token or an error if the token literal does not
94 // denote a valid float64.
95 func (t *Token) Float64Value() (float64, error) {
96 return strconv.ParseFloat(string(t.Lit), 64)
97 }
98
99 // IDValue returns the string representation of an identifier token.
100 func (t *Token) IDValue() string {
101 return string(t.Lit)
102 }
103
104 // Int32Value returns the int32 value of the token or an error if the token literal does not
105 // denote a valid float64.
106 func (t *Token) Int32Value() (int32, error) {
107 if v, err := strconv.ParseInt(string(t.Lit), 10, 64); err != nil {
108 return 0, err
109 } else {
110 return int32(v), nil
111 }
112 }
113
114 // Int64Value returns the int64 value of the token or an error if the token literal does not
115 // denote a valid float64.
116 func (t *Token) Int64Value() (int64, error) {
117 return strconv.ParseInt(string(t.Lit), 10, 64)
118 }
119
120 // UTF8Rune decodes the UTF8 rune in the token literal. It returns utf8.RuneError if
121 // the token literal contains an invalid rune.
122 func (t *Token) UTF8Rune() (rune, error) {
123 r, _ := utf8.DecodeRune(t.Lit)
124 if r == utf8.RuneError {
125 err := fmt.Errorf("Invalid rune")
126 return r, err
127 }
128 return r, nil
129 }
130
131 // StringValue returns the string value of the token literal.
132 func (t *Token) StringValue() string {
133 return string(t.Lit[1 : len(t.Lit)-1])
57134 }
58135
59136 var TokMap = TokenMap{
88 "unicode/utf8"
99 )
1010
11 /* Interface */
11 // Interface.
1212
13 /*
14 Convert the literal value of a scanned token to rune
15 */
13 // RuneValue will convert the literal value of a scanned token to a rune.
1614 func RuneValue(lit []byte) rune {
1715 if lit[1] == '\\' {
1816 return escapeCharVal(lit)
2422 return r
2523 }
2624
27 /*
28 Convert the literal value of a scanned token to int64
29 */
25 // UintValue will attempt to parse a byte-slice as a signed base-10 64-bit integer.
3026 func IntValue(lit []byte) (int64, error) {
3127 return strconv.ParseInt(string(lit), 10, 64)
3228 }
3329
34 /*
35 Convert the literal value of a scanned token to uint64
36 */
30 // UintValue will attempt to parse a byte-slice as an unsigned base-10 64-bit integer.
3731 func UintValue(lit []byte) (uint64, error) {
3832 return strconv.ParseUint(string(lit), 10, 64)
3933 }
4034
41 /* Util */
42
35 // Helpers.
4336 func escapeCharVal(lit []byte) rune {
4437 var i, base, max uint32
4538 offset := 2
6868 SupportingFunction:cluster_Supporting->CoreFunction:cluster_Core;
6969 Hello->CoreFunction:cluster_Core;
7070 subgraph cluster_Core {
71 CoreFunction;
72
73 }
74 ;
75 subgraph cluster_Development {
76 DevelopmentFunction;
77
78 }
79 ;
80 subgraph cluster_Supporting {
81 SupportingFunction;
82
83 }
84 ;
85 Hello;
86 World;
87
71 CoreFunction;
72 };
73 subgraph cluster_Development {
74 DevelopmentFunction;
75 };
76 subgraph cluster_Supporting {
77 SupportingFunction;
78 };
79 Hello;
80 World;
8881 }
8982 `
9083
10194 SupportingFunction:cluster_Supporting->CoreFunction:cluster_Core;
10295 Hello->CoreFunction:cluster_Core;
10396 subgraph cluster_Core {
104 CoreFunction;
105
106 }
107 ;
108 subgraph cluster_Development {
109
110 }
111 ;
112 subgraph cluster_Supporting {
113 SupportingFunction;
114
115 }
116 ;
117 Hello;
118 World;
119
97 CoreFunction;
98 };
99 subgraph cluster_Development {
100
101 };
102 subgraph cluster_Supporting {
103 SupportingFunction;
104 };
105 Hello;
106 World;
120107 }
121108 `
122109 if g.String() != expected {
133120 expected = `digraph G {
134121 SupportingFunction:cluster_Supporting->CoreFunction:cluster_Core;
135122 subgraph cluster_Core {
136 CoreFunction;
137
138 }
139 ;
140 subgraph cluster_Development {
141
142 }
143 ;
144 subgraph cluster_Supporting {
145 SupportingFunction;
146
147 }
148 ;
149
123 CoreFunction;
124 };
125 subgraph cluster_Development {
126
127 };
128 subgraph cluster_Supporting {
129 SupportingFunction;
130 };
150131 }
151132 `
152133 if g.String() != expected {
159140
160141 expected = `digraph G {
161142 subgraph cluster_Core {
162 CoreFunction;
163
164 }
165 ;
166 subgraph cluster_Development {
167
168 }
169 ;
170 subgraph cluster_Supporting {
171
172 }
173 ;
174
143 CoreFunction;
144 };
145 subgraph cluster_Development {
146
147 };
148 subgraph cluster_Supporting {
149
150 };
175151 }
176152 `
177153
186162 expected = `digraph G {
187163 subgraph cluster_Core {
188164
189 }
190 ;
191 subgraph cluster_Development {
192
193 }
194 ;
195 subgraph cluster_Supporting {
196
197 }
198 ;
199
165 };
166 subgraph cluster_Development {
167
168 };
169 subgraph cluster_Supporting {
170
171 };
200172 }
201173 `
202174
269241 Hello->CoreFunction:cluster_Core;
270242 Hello->cluster_FooBar;
271243 subgraph cluster_Core {
272 label=Core;
273 CoreFunction;
274
275 }
276 ;
277 subgraph cluster_Development {
278 label=Development;
279 DevelopmentFunction;
280
281 }
282 ;
244 label=Core;
245 CoreFunction;
246 };
247 subgraph cluster_Development {
248 label=Development;
249 DevelopmentFunction;
250 };
283251 subgraph cluster_FooBar {
284252
285 }
286 ;
287 subgraph cluster_Supporting {
288 label=Supporting;
289 SupportingFunction;
290
291 }
292 ;
293 Hello;
294 World;
295
253 };
254 subgraph cluster_Supporting {
255 label=Supporting;
256 SupportingFunction;
257 };
258 Hello;
259 World;
296260 }
297261 `
298262 if g.String() != expected {
309273 Hello->CoreFunction:cluster_Core;
310274 Hello->cluster_FooBar;
311275 subgraph cluster_Core {
312 label=Core;
313 CoreFunction;
314
315 }
316 ;
276 label=Core;
277 CoreFunction;
278 };
317279 subgraph cluster_FooBar {
318280
319 }
320 ;
321 subgraph cluster_Supporting {
322 label=Supporting;
323 SupportingFunction;
324
325 }
326 ;
327 Hello;
328 World;
329
281 };
282 subgraph cluster_Supporting {
283 label=Supporting;
284 SupportingFunction;
285 };
286 Hello;
287 World;
330288 }
331289 `
332290 if g.String() != expected {
342300 Hello->CoreFunction:cluster_Core;
343301 Hello->cluster_FooBar;
344302 subgraph cluster_Core {
345 label=Core;
346 CoreFunction;
347
348 }
349 ;
303 label=Core;
304 CoreFunction;
305 };
350306 subgraph cluster_FooBar {
351307
352 }
353 ;
354 Hello;
355 World;
356
308 };
309 Hello;
310 World;
357311 }
358312 `
359313 if g.String() != expected {
369323 Hello->cluster_FooBar;
370324 subgraph cluster_FooBar {
371325
372 }
373 ;
374 Hello;
375 World;
376
326 };
327 Hello;
328 World;
377329 }
378330 `
379331 if g.String() != expected {
388340 Hello->World;
389341 Hello;
390342 World;
391
392 }
393 `
394 if g.String() != expected {
395 t.Fatalf("output is not expected")
396 }
397 }
343 }
344 `
345 if g.String() != expected {
346 t.Fatalf("output is not expected")
347 }
348 }