-
Notifications
You must be signed in to change notification settings - Fork 5
/
skip.go
108 lines (103 loc) · 1.86 KB
/
skip.go
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package udwGoParser
import (
"github.com/tachyon-protocol/udw/udwGoSource/udwGoReader"
)
func (gofile *file) readGoType(r *udwGoReader.Reader) {
r.MustReadMatch([]byte("type"))
r.ReadAllSpace()
b := r.ReadByte()
if b == '(' {
for {
r.ReadAllSpace()
b = r.ReadByte()
if b == ')' {
return
}
r.UnreadByte()
name := readIdentifier(r)
r.ReadAllSpace()
typ := gofile.readType(r)
gofile.namedTypeList = append(gofile.namedTypeList, &NamedType{
PkgImportPath: gofile.pkg.pkgImportPath,
Name: string(name),
UnderType: typ,
})
}
} else {
r.UnreadByte()
name := readIdentifier(r)
r.ReadAllSpace()
typ := gofile.readType(r)
gofile.namedTypeList = append(gofile.namedTypeList, &NamedType{
PkgImportPath: gofile.pkg.pkgImportPath,
Name: string(name),
UnderType: typ,
})
return
}
}
func (gofile *file) readGoVar(r *udwGoReader.Reader) {
r.MustReadMatch([]byte("var"))
r.ReadAllSpace()
b := r.ReadByte()
if b == '(' {
readMatchSmallParantheses(r)
return
}
r.UnreadByte()
readIdentifier(r)
r.ReadAllSpace()
b = r.ReadByte()
if b == '=' {
r.ReadAllSpace()
}
for {
if b == '"' || b == '`' {
r.UnreadByte()
mustReadGoString(r)
}
if b == '\'' {
r.UnreadByte()
mustReadGoChar(r)
}
if b == '\n' {
return
}
if b == '{' {
readMatchBigParantheses(r)
}
if b == '(' {
readMatchSmallParantheses(r)
}
if r.IsEof() {
return
}
b = r.ReadByte()
}
}
func (gofile *file) readGoConst(r *udwGoReader.Reader) {
r.MustReadMatch([]byte("const"))
r.ReadAllSpace()
b := r.ReadByte()
if b == '(' {
readMatchSmallParantheses(r)
return
}
for {
if b == '"' || b == '`' {
r.UnreadByte()
mustReadGoString(r)
}
if b == '\'' {
r.UnreadByte()
mustReadGoChar(r)
}
if b == '\n' {
return
}
if r.IsEof() {
return
}
b = r.ReadByte()
}
}