The content of round bracket now returns an expressione term. This way the content is decoupled from external terms.
This commit is contained in:
+4
-3
@@ -7,7 +7,8 @@ package expr
|
||||
import "fmt"
|
||||
|
||||
// -------- expr term
|
||||
func newExprTerm(tk *Token) *term {
|
||||
func newExprTerm(root *term) *term {
|
||||
tk := NewValueToken(root.tk.row, root.tk.col, SymExpression, root.source(), root)
|
||||
return &term{
|
||||
tk: *tk,
|
||||
parent: nil,
|
||||
@@ -20,8 +21,8 @@ func newExprTerm(tk *Token) *term {
|
||||
|
||||
// -------- eval expr
|
||||
func evalExpr(ctx ExprContext, self *term) (v any, err error) {
|
||||
if expr, ok := self.value().(Expr); ok {
|
||||
v, err = expr.eval(ctx, false)
|
||||
if expr, ok := self.value().(*term); ok {
|
||||
v, err = expr.compute(ctx)
|
||||
} else {
|
||||
err = fmt.Errorf("expression expected, got %T", self.value())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user