-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathastResult.go
More file actions
34 lines (28 loc) · 766 Bytes
/
astResult.go
File metadata and controls
34 lines (28 loc) · 766 Bytes
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
package main
import (
"bytes"
"fmt"
)
//astResult contains the result of the AST analysis
type astResult struct {
//array of all variable declarations
variablesDeclarations []variableDescription
}
type variableDescription struct {
//type name, in a short version, ex: int, float, Foo...
typeName string
//variable name
varName string
}
//String returns the value of results as a formatted string
func (v *variableDescription) String() string {
return fmt.Sprintf("{%s}{%s}", v.varName, v.typeName)
}
//String returns the value of results as a formatted string
func (r *astResult) String() string {
var buffer bytes.Buffer
for _, e := range r.variablesDeclarations {
buffer.WriteString(fmt.Sprintf("%s\n", e.String()))
}
return buffer.String()
}