MCPcopy
hub / github.com/uber/aresdb / scanIdent

Method scanIdent

query/expr/scanner.go:172–203  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

170}
171
172func (s *Scanner) scanIdent() (tok Token, pos Pos, lit string) {
173 // Save the starting position of the identifier.
174 _, pos = s.r.read()
175 s.r.unread()
176
177 var buf bytes.Buffer
178 for {
179 if ch, _ := s.r.read(); ch == eof {
180 break
181 } else if ch == '`' {
182 tok0, pos0, lit0 := s.scanString()
183 if tok0 == BADSTRING || tok0 == BADESCAPE {
184 return tok0, pos0, lit0
185 }
186 return IDENT, pos, lit0
187 } else if isIdentChar(ch) {
188 s.r.unread()
189 buf.WriteString(ScanBareIdent(s.r))
190 } else {
191 s.r.unread()
192 break
193 }
194 }
195 lit = buf.String()
196
197 // If the literal matches a keyword then return that keyword.
198 if tok = Lookup(lit); tok != IDENT {
199 return tok, pos, ""
200 }
201
202 return IDENT, pos, lit
203}
204
205// scanString consumes a contiguous string of non-quote characters.
206// Quote characters can be consumed if they're first escaped with a backslash.

Callers 1

scanMethod · 0.95

Calls 7

scanStringMethod · 0.95
isIdentCharFunction · 0.85
ScanBareIdentFunction · 0.85
LookupFunction · 0.85
unreadMethod · 0.80
readMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected