Skip to content

Commit

Permalink
use Call, remove FnCallExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
wuyq101 committed Oct 17, 2024
1 parent fbb44b2 commit bdae111
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
15 changes: 0 additions & 15 deletions ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func (*StringLit) node() {}
func (*TableName) node() {}
func (*Type) node() {}
func (*UnaryExpr) node() {}
func (*FnCallExpr) node() {}
func (*UpdateStatement) node() {}
func (*UpsertClause) node() {}
func (*UsingConstraint) node() {}
Expand Down Expand Up @@ -94,7 +93,6 @@ func (*QualifiedRef) expr() {}
func (*Range) expr() {}
func (*StringLit) expr() {}
func (*UnaryExpr) expr() {}
func (*FnCallExpr) expr() {}

// ExprString returns the string representation of expr.
// Returns a blank string if expr is nil.
Expand Down Expand Up @@ -364,19 +362,6 @@ func (expr *UnaryExpr) String() string {
}
}

type FnCallExpr struct {
Fn Token // function
X Expr // param expression
}

func (expr *FnCallExpr) String() string {
paran, ok := expr.X.(*ParenExpr)
if ok {
return expr.Fn.String() + "(" + paran.X.String() + ")"
}
return expr.Fn.String() + "(" + expr.X.String() + ")"
}

type BinaryExpr struct {
X Expr // lhs
Op Token // operator
Expand Down
3 changes: 2 additions & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,9 @@ func (p *Parser) parseOperand() (expr Expr, err error) {
if err != nil {
return nil, err
}
expr = expr.(*ParenExpr).X
}
return &FnCallExpr{Fn: VALUES, X: expr}, nil
return &Call{Name: &Ident{Name: "VALUES"}, Args: []Expr{expr}}, nil

case IDENT, QIDENT:
ident := identByNameAndTok(lit, tok)
Expand Down

0 comments on commit bdae111

Please sign in to comment.