// curExpr returns current expression
184095
func (v *evalVisitor) curExpr() *ast.Expression {
	if len(v.exprs) == 0 {
		return nil
	}

	return v.exprs[len(v.exprs)-1]
}
908864
func IsValidExpression(expr string) bool {
	_, err := parseExpression(expr)
	return err == nil
}
664158
func (t *tree) parseExpr(prec int) ast.Node {
	n := t.parseExprFirstTerm()
	var tok item
	for {
		tok = t.next()
		q := precedence[tok.typ]
		if !isBinaryOp(tok.typ) || q < prec {
			break
		}
		q++
		n = newBinaryOpNode(tok, n, t.parseExpr(q))
	}
	if prec == 0 && tok.typ == itemTernIf {
		return t.parseTernary(n)
	}
	t.backup()
	return n
}
1174144
func isPushableExpr(paramName string, expr semantic.Expression) (bool, error) {
	switch e := expr.(type) {
	case *semantic.LogicalExpression:
		b, err := isPushableExpr(paramName, e.Left)
		if err != nil {
			return false, err
		}

		if !b {
			return false, nil
		}

		return isPushableExpr(paramName, e.Right)

	case *semantic.BinaryExpression:
		if isPushablePredicate(paramName, e) {
			return true, nil
		}
	}

	return false, nil
}
152980
func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
	return Regexp(a.t, rx, str, msgAndArgs...)
}
226245
func (p *parser) parseExprList() (list []ast.Expr) {
	if p.trace {
		defer un(trace(p, "ExpressionList"))
	}

	list = append(list, p.parseExpr())
	for p.tok == token.COMMA {
		p.next()
		list = append(list, p.parseExpr())
	}

	return
}
788796
func (v *evalVisitor) popExpr() *ast.Expression {
	if len(v.exprs) == 0 {
		return nil
	}

	var result *ast.Expression
	result, v.exprs = v.exprs[len(v.exprs)-1], v.exprs[:len(v.exprs)-1]

	return result
}
359859
func (exp *GetAttrExpr) All() []Node {
	res := []Node{exp.Cont, exp.Attr}
	for _, v := range exp.Args {
		res = append(res, v)
	}
	return res
}
996500
func (l *lex) spanRegexp(re *regexp.Regexp) (before string, match string, success bool) {
	loc := re.FindStringSubmatchIndex(l.s[l.p:])
	if loc == nil {
		return "", "", false
	}
	success = true
	start, end := loc[2], loc[3]
	before = l.s[l.p : l.p+start]
	match = l.s[l.p:][start:end]
	l.p += end
	return
}
674072
func RemoveDupExprs(ctx sessionctx.Context, exprs []Expression) []Expression {
	res := make([]Expression, 0, len(exprs))
	exists := make(map[string]struct{}, len(exprs))
	sc := ctx.GetSessionVars().StmtCtx
	for _, expr := range exprs {
		key := string(expr.HashCode(sc))
		if _, ok := exists[key]; !ok || isMutableEffectsExpr(expr) {
			res = append(res, expr)
			exists[key] = struct{}{}
		}
	}
	return res
}
174565
func (p *Planner) planExpr(e *ast.Expr, iter planiter) error {

	if e.Negated {
		return p.planNot(e, iter)
	}

	if len(e.With) > 0 {
		return fmt.Errorf("with keyword not implemented")
	}

	if e.IsCall() {
		return p.planExprCall(e, iter)
	}

	return p.planExprTerm(e, iter)
}
1043814
func cloneExpr(expr Expression) Expression {
	switch expr := expr.(type) {
	case *ActionExpr:
		return &ActionExpr{
			Code:   expr.Code,
			Expr:   cloneExpr(expr.Expr),
			FuncIx: expr.FuncIx,
			p:      expr.p,
		}
	case *AndExpr:
		return &AndExpr{
			Expr: cloneExpr(expr.Expr),
			p:    expr.p,
		}
	case *AndCodeExpr:
		return &AndCodeExpr{
			Code:   expr.Code,
			FuncIx: expr.FuncIx,
			p:      expr.p,
		}
	case *CharClassMatcher:
		return &CharClassMatcher{
			Chars:          append([]rune{}, expr.Chars...),
			IgnoreCase:     expr.IgnoreCase,
			Inverted:       expr.Inverted,
			posValue:       expr.posValue,
			Ranges:         append([]rune{}, expr.Ranges...),
			UnicodeClasses: append([]string{}, expr.UnicodeClasses...),
		}
	case *ChoiceExpr:
		alts := make([]Expression, 0, len(expr.Alternatives))
		for i := 0; i < len(expr.Alternatives); i++ {
			alts = append(alts, cloneExpr(expr.Alternatives[i]))
		}
		return &ChoiceExpr{
			Alternatives: alts,
			p:            expr.p,
		}
	case *LabeledExpr:
		return &LabeledExpr{
			Expr:  cloneExpr(expr.Expr),
			Label: expr.Label,
			p:     expr.p,
		}
	case *NotExpr:
		return &NotExpr{
			Expr: cloneExpr(expr.Expr),
			p:    expr.p,
		}
	case *NotCodeExpr:
		return &NotCodeExpr{
			Code:   expr.Code,
			FuncIx: expr.FuncIx,
			p:      expr.p,
		}
	case *OneOrMoreExpr:
		return &OneOrMoreExpr{
			Expr: cloneExpr(expr.Expr),
			p:    expr.p,
		}
	case *SeqExpr:
		exprs := make([]Expression, 0, len(expr.Exprs))
		for i := 0; i < len(expr.Exprs); i++ {
			exprs = append(exprs, cloneExpr(expr.Exprs[i]))
		}
		return &SeqExpr{
			Exprs: exprs,
			p:     expr.p,
		}
	case *StateCodeExpr:
		return &StateCodeExpr{
			p:      expr.p,
			Code:   expr.Code,
			FuncIx: expr.FuncIx,
		}
	case *ZeroOrMoreExpr:
		return &ZeroOrMoreExpr{
			Expr: cloneExpr(expr.Expr),
			p:    expr.p,
		}
	case *ZeroOrOneExpr:
		return &ZeroOrOneExpr{
			Expr: expr.Expr,
			p:    expr.p,
		}
	}
	return expr
}
1368979
func (session *Session) SetExpr(column string, expression string) *Session {
	session.statement.SetExpr(column, expression)
	return session
}
587953
func (p *parser) parseSexpr() *ast.SubExpression {
	// OPEN_SEXPR
	tok := p.shift()

	result := ast.NewSubExpression(tok.Pos, tok.Line)

	// helperName param* hash?
	result.Expression = p.parseExpression(tok)

	// CLOSE_SEXPR
	tok = p.shift()
	if tok.Kind != lexer.TokenCloseSexpr {
		errExpected(lexer.TokenCloseSexpr, tok)
	}

	return result
}
583262
func (s *DB) QueryExpr() *expr {
	scope := s.NewScope(s.Value)
	scope.InstanceSet("skip_bindvar", true)
	scope.prepareQuerySQL()

	return Expr(scope.SQL, scope.SQLVars...)
}
359488
func (v *evalVisitor) pushExpr(expression *ast.Expression) {
	v.exprs = append(v.exprs, expression)
}
851720
func (l *Lexer) indexRegexp(r *regexp.Regexp) int {
	loc := r.FindStringIndex(l.input[l.pos:])
	if loc == nil {
		return -1
	}
	return loc[0]
}