MCPcopy Create free account
hub / github.com/go-pg/pg / ReadIdentifier

Method ReadIdentifier

internal/parser/parser.go:85–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83}
84
85func (p *Parser) ReadIdentifier() (string, bool) {
86 if p.i < len(p.b) && p.b[p.i] == '(' {
87 s := p.i + 1
88 if ind := bytes.IndexByte(p.b[s:], ')'); ind != -1 {
89 b := p.b[s : s+ind]
90 p.i = s + ind + 1
91 return internal.BytesToString(b), false
92 }
93 }
94
95 ind := len(p.b) - p.i
96 var alpha bool
97 for i, c := range p.b[p.i:] {
98 if isNum(c) {
99 continue
100 }
101 if isAlpha(c) || (i > 0 && alpha && c == '_') {
102 alpha = true
103 continue
104 }
105 ind = i
106 break
107 }
108 if ind == 0 {
109 return "", false
110 }
111 b := p.b[p.i : p.i+ind]
112 p.i += ind
113 return internal.BytesToString(b), !alpha
114}
115
116func (p *Parser) ReadNumber() int {
117 ind := len(p.b) - p.i

Callers 1

appendMethod · 0.80

Calls 3

BytesToStringFunction · 0.92
isNumFunction · 0.85
isAlphaFunction · 0.85

Tested by

no test coverage detected