MCPcopy Index your code
hub / github.com/perkeep/perkeep / parseExpression

Function parseExpression

pkg/search/expr.go:327–359  ·  view source on GitHub ↗
(ctx context.Context, exp string)

Source from the content-addressed store, hash-verified

325}
326
327func parseExpression(ctx context.Context, exp string) (*SearchQuery, error) {
328 base := &Constraint{
329 Permanode: &PermanodeConstraint{
330 SkipHidden: true,
331 },
332 }
333 sq := &SearchQuery{
334 Constraint: base,
335 }
336
337 exp = strings.TrimSpace(exp)
338 if exp == "" {
339 return sq, nil
340 }
341 p := newParser(ctx, exp)
342
343 c, err := p.parseExp()
344 if err != nil {
345 return nil, err
346 }
347 lastToken := p.next()
348 if lastToken.typ != tokenEOF {
349 switch lastToken.typ {
350 case tokenClose:
351 return nil, newParseExpError(noMatchingOpening, *lastToken)
352 }
353 return nil, newParseExpError(trailingTokens, *lastToken)
354 }
355 if c != nil {
356 sq.Constraint = andConst(base, c)
357 }
358 return sq, nil
359}

Callers 3

checkValidMethod · 0.85
evalSearchInputFunction · 0.85
TestParseExpressionFunction · 0.85

Calls 5

newParserFunction · 0.85
newParseExpErrorFunction · 0.85
andConstFunction · 0.85
parseExpMethod · 0.80
nextMethod · 0.45

Tested by 1

TestParseExpressionFunction · 0.68