-
Notifications
You must be signed in to change notification settings - Fork 4
/
regex.go
60 lines (46 loc) · 2.07 KB
/
regex.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
package fields
import (
"regexp"
)
const (
schemaRegexString = `__schema`
trueIncludesRegexString = `\s{1,}@.*true.*?{`
falseIncludesRegexString = `\s{1,}@.*false.*?{`
includesRegexString = `\s{1,}@.*?{`
paramsRegexString = `(?sm)\(.*?\)`
commasRegexString = `,`
aliasMergeRegexString = `.*?:`
aliasReplaceRegexString = `:\s{0,}\w{1,}\b`
spacesRegexString = `\s{1,}`
fragmentsStartRegexString = `(?sm)fragment(.|\n)*?{`
partialFragmentRegexString = `\.\.\.`
fragmentNameStartRegexString = `(?sm)fragment(\s|\n){1,}`
fragmentNameEndRegexString = `(?sm)\s{1,}on(.|\n)*`
fragmentBodyStartRegexString = `(?sm)fragment(.|\n)*?{`
fragmentBodyEndRegexString = `(?sm)}(\s|\n)*\z`
queryStartRegexString = `(?sm)\A(.|\n)*?{`
queryEndRegexString = `(?sm)}(\s|\n)*\z`
levelUpRegexString = `{`
levelDownRegexString = `}`
)
var (
schemaRegex = regexp.MustCompile(schemaRegexString)
trueIncludesRegex = regexp.MustCompile(trueIncludesRegexString)
falseIncludesRegex = regexp.MustCompile(falseIncludesRegexString)
includesRegex = regexp.MustCompile(includesRegexString)
paramsRegex = regexp.MustCompile(paramsRegexString)
commasRegex = regexp.MustCompile(commasRegexString)
aliasMergeRegex = regexp.MustCompile(aliasMergeRegexString)
aliasReplaceRegex = regexp.MustCompile(aliasReplaceRegexString)
spacesRegex = regexp.MustCompile(spacesRegexString)
fragmentsStartRegex = regexp.MustCompile(fragmentsStartRegexString)
partialFragmentRegex = regexp.MustCompile(partialFragmentRegexString)
fragmentNameStartRegex = regexp.MustCompile(fragmentNameStartRegexString)
fragmentNameEndRegex = regexp.MustCompile(fragmentNameEndRegexString)
fragmentBodyStartRegex = regexp.MustCompile(fragmentBodyStartRegexString)
fragmentBodyEndRegex = regexp.MustCompile(fragmentBodyEndRegexString)
queryStartRegex = regexp.MustCompile(queryStartRegexString)
queryEndRegex = regexp.MustCompile(queryEndRegexString)
levelUpRegex = regexp.MustCompile(levelUpRegexString)
levelDownRegex = regexp.MustCompile(levelDownRegexString)
)