// SearchLiteral does a literal string search (no regexp).
761414
func (i *Index) SearchLiteral(term string, threshold int) []*Result {
	term = strings.ToLower(term)
	buf := []*Result{}
	for k, v := range i.lines {
		lk := strings.ToLower(k)
		lv := strings.ToLower(v)
		res := strings.Index(lv, term)
		if score := i.calcScore(res, lv); res != -1 && score < threshold {
			parts := strings.Split(lk, verSep) // Remove version, if it is there.
			buf = append(buf, &Result{Name: parts[0], Score: score, Chart: i.charts[k]})
		}
	}
	return buf
}
371966
func (d *decodeState) literal(v reflect.Value) {
	start := d.takePos()
	op, end := d.takeRecord()
	if op != scanEndLiteral {
		d.error(errPhase)
	}
	d.literalStore(d.data[start:end+1], v, false)
}
659220
func (t *tree) parseListLiteral(first item, expr ast.Node) ast.Node {
	var items []ast.Node
	items = append(items, expr)
	for {
		items = append(items, t.parseExpr(0))
		next := t.next()
		if next.typ == itemRightBracket {
			return &ast.ListLiteralNode{first.pos, items}
		}
		if next.typ != itemComma {
			t.unexpected(next, "parsing value list")
		}
	}
}
1128010
func lexPathLiteral(l *Lexer) lexFunc {
	for {
		r := l.next()
		if r == eof || r == '\n' {
			return l.errorf("Unterminated path literal")
		}

		if r == ']' {
			break
		}
	}

	l.emit(TokenID)

	return lexExpression
}
173105
func (x *Index) Search(c context.Context, query string, opts *SearchOptions) *Iterator {
	t := &Iterator{
		c:           c,
		index:       x,
		searchQuery: query,
		more:        moreSearch,
		limit:       -1,
	}
	if opts != nil {
		if opts.Limit > 0 {
			t.limit = opts.Limit
		}
		t.fields = opts.Fields
		t.idsOnly = opts.IDsOnly
		t.sort = opts.Sort
		t.exprs = opts.Expressions
	}
	return t
}
123787
func (t *typeChecker) AcceptNumericLiteral(v tree.NumericLiteral) {
	if t.expectBoolean {
		t.result = fmt.Errorf("expected boolean expression but found: %s", tree.ExpressionString(v))
	}
}
975411
func (p *Parser) lookahead() (Token, string) {
	tok, lit := p.scannedItems[p.position].tok, p.scannedItems[p.position].literal
	return tok, lit
}
1094963
func (l *StringLiteral) IsTimeLiteral() bool {
	return isDateTimeString(l.Val) || isDateString(l.Val)
}
190612
func (i *ComponentInput) Search() error {
	if i.Searcher == nil {
		return ErrNoMatch{Value: i.Value, Qualifier: "no searcher defined"}
	}
	matches, err := i.Searcher.Search(false, i.Value)
	if matches != nil {
		i.SearchMatches = matches
	}
	return errors.NewAggregate(err)
}
306899
func (p *Parser) lookahead(context ParserContext) (Token, string) {
	tok, lit := p.scannedItems[p.position].tok, p.scannedItems[p.position].literal
	if context == Values {
		switch tok {
		case InToken, NotInToken:
			tok = IdentifierToken
		}
	}
	return tok, lit
}
1344643
func (t *Tree) Search(topic string) []interface{} {
	t.mutex.RLock()
	defer t.mutex.RUnlock()

	segments := strings.Split(topic, t.Separator)
	values := t.search([]interface{}{}, 0, segments, t.root)

	return t.clean(values)
}
1213147
func (r *RegexLiteral) String() string {
	if r.Val != nil {
		return fmt.Sprintf("/%s/", strings.Replace(r.Val.String(), `/`, `\/`, -1))
	}
	return ""
}
1122278
func scanLiteral(s string, startPos ast.Pos, nested bool) (string, *Token) {
	litLen := 0
	pos := startPos
	var terminator *Token
	for {

		if litLen >= len(s) {
			if nested {
				// We've ended in the middle of a quoted string,
				// which means this token is actually invalid.
				return "", &Token{
					Type:    INVALID,
					Content: s,
					Pos:     startPos,
				}
			}
			terminator = &Token{
				Type:    EOF,
				Content: "",
				Pos:     pos,
			}
			break
		}

		next := s[litLen]

		if next == '$' && len(s) > litLen+1 {
			follow := s[litLen+1]

			if follow == '{' {
				terminator = &Token{
					Type:    BEGIN,
					Content: s[litLen : litLen+2],
					Pos:     pos,
				}
				pos.Column = pos.Column + 2
				break
			} else if follow == '$' {
				// Double-$ escapes the special processing of $,
				// so we will consume both characters here.
				pos.Column = pos.Column + 2
				litLen = litLen + 2
				continue
			}
		}

		// special handling that applies only to quoted strings
		if nested {
			if next == '"' {
				terminator = &Token{
					Type:    CQUOTE,
					Content: s[litLen : litLen+1],
					Pos:     pos,
				}
				pos.Column = pos.Column + 1
				break
			}

			// Escaped quote marks do not terminate the string.
			//
			// All we do here in the scanner is avoid terminating a string
			// due to an escaped quote. The parser is responsible for the
			// full handling of escape sequences, since it's able to produce
			// better error messages than we can produce in here.
			if next == '\\' && len(s) > litLen+1 {
				follow := s[litLen+1]

				if follow == '"' {
					// \" escapes the special processing of ",
					// so we will consume both characters here.
					pos.Column = pos.Column + 2
					litLen = litLen + 2
					continue
				} else if follow == '\\' {
					// \\ escapes \
					// so we will consume both characters here.
					pos.Column = pos.Column + 2
					litLen = litLen + 2
					continue
				}
			}
		}

		if next == '\n' {
			pos.Column = 1
			pos.Line++
			litLen++
		} else {
			pos.Column++

			// "Column" measures runes, so we need to actually consume
			// a valid UTF-8 character here.
			_, size := utf8.DecodeRuneInString(s[litLen:])
			litLen = litLen + size
		}

	}

	return s[:litLen], terminator
}
1318176
func (p *Parser) scan() {
	for {
		token, literal := p.l.Lex()
		p.scannedItems = append(p.scannedItems, ScannedItem{token, literal})
		if token == EndOfStringToken {
			break
		}
	}
}
1053031
func (s *booleanCompilerVisitor) AcceptNumericLiteral(v tree.NumericLiteral) {
	s.err = errors.New("a numeric literal was found in a boolean expression - this is likely a programmer error")
}
702475
func Literal(s string) Formatter {
	return func(buffer Buffer, event *cue.Event) {
		buffer.AppendString(s)
	}
}
463424
func NewNumberLiteral(pos int, line int, val float64, isInt bool, original string) *NumberLiteral {
	return &NumberLiteral{
		NodeType: NodeNumber,
		Loc:      Loc{pos, line},

		Value:    val,
		IsInt:    isInt,
		Original: original,
	}
}