File: directive.go

package info (click to toggle)
golang-github-graph-gophers-graphql-go 0.0~git20180609.bb97385-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, buster-backports
  • size: 632 kB
  • sloc: makefile: 4
file content (32 lines) | stat: -rw-r--r-- 561 bytes parent folder | download | duplicates (2)
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
package common

type Directive struct {
	Name Ident
	Args ArgumentList
}

func ParseDirectives(l *Lexer) DirectiveList {
	var directives DirectiveList
	for l.Peek() == '@' {
		l.ConsumeToken('@')
		d := &Directive{}
		d.Name = l.ConsumeIdentWithLoc()
		d.Name.Loc.Column--
		if l.Peek() == '(' {
			d.Args = ParseArguments(l)
		}
		directives = append(directives, d)
	}
	return directives
}

type DirectiveList []*Directive

func (l DirectiveList) Get(name string) *Directive {
	for _, d := range l {
		if d.Name.Name == name {
			return d
		}
	}
	return nil
}