MCPcopy
hub / github.com/perkeep/perkeep / atomWords

Method atomWords

pkg/search/expr.go:254–293  ·  view source on GitHub ↗

AtomWords returns the parsed atom, the starting position of this atom and an error.

()

Source from the content-addressed store, hash-verified

252// AtomWords returns the parsed atom, the starting position of this
253// atom and an error.
254func (p *parser) atomWords() (a atom, start int, err error) {
255 i := p.peek()
256 start = i.start
257 a = atom{}
258 switch i.typ {
259 case tokenLiteral:
260 err = newParseExpError(noLiteralSupport, *i)
261 return
262 case tokenQuotedLiteral:
263 err = newParseExpError(noQuotedLiteralSupport, *i)
264 return
265 case tokenColon:
266 err = newParseExpError(predicateError, *i)
267 return
268 case tokenPredicate:
269 i := p.next()
270 a.predicate = i.val
271 }
272 for {
273 switch p.peek().typ {
274 case tokenColon:
275 p.next()
276 continue
277 case tokenArg:
278 i := p.next()
279 a.args = append(a.args, i.val)
280 continue
281 case tokenQuotedArg:
282 i := p.next()
283 var uq string
284 uq, err = strconv.Unquote(i.val)
285 if err != nil {
286 return
287 }
288 a.args = append(a.args, uq)
289 continue
290 }
291 return
292 }
293}
294
295func (p *parser) parseAtom() (*Constraint, error) {
296 a, start, err := p.atomWords()

Callers 1

parseAtomMethod · 0.95

Calls 3

peekMethod · 0.95
nextMethod · 0.95
newParseExpErrorFunction · 0.85

Tested by

no test coverage detected