-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnamespace.go
48 lines (41 loc) · 871 Bytes
/
namespace.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
package thrifter
type Namespace struct {
NodeCommonField
Name string
Value string
Options []*Option
}
func NewNamespace(start *Token, parent Node) *Namespace {
return &Namespace{
NodeCommonField: NodeCommonField{
Parent: parent,
StartToken: start,
},
}
}
func (r *Namespace) NodeValue() interface{} {
return *r
}
func (r *Namespace) NodeType() string {
return "Namespace"
}
func (r *Namespace) String() string {
return toString(r.StartToken, r.EndToken)
}
func (r *Namespace) parse(p *Parser) (err error) {
identTok := p.nextIdent(true)
r.Name = identTok.Raw
identTok = p.nextIdent(true)
r.Value = identTok.Raw
ru := p.peekNonWhitespace()
if toToken(string(ru)) != T_LEFTPAREN {
r.EndToken = identTok
return
}
p.next() // consume (
r.Options, r.EndToken, err = parseOptions(p, r)
if err != nil {
return err
}
return
}