From bdae1112ec51968a7e803bc9e57b23f10ce7d7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E8=8B=B1=E5=BC=BA?= Date: Thu, 17 Oct 2024 11:48:36 +0800 Subject: [PATCH] use Call, remove FnCallExpr --- ast.go | 15 --------------- parser.go | 3 ++- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/ast.go b/ast.go index 5361d1a..1f892f4 100644 --- a/ast.go +++ b/ast.go @@ -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() {} @@ -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. @@ -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 diff --git a/parser.go b/parser.go index 84be4b3..05d4ca2 100644 --- a/parser.go +++ b/parser.go @@ -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)