moved a subset of source file to the kern package

This commit is contained in:
2026-04-27 19:43:37 +02:00
parent f100adead3
commit 4d910dd069
107 changed files with 2080 additions and 1380 deletions
+15 -9
View File
@@ -6,15 +6,21 @@ package expr
import (
"errors"
"git.portale-stac.it/go-pkg/expr/kern"
)
// -------- function call term
func newFuncCallTerm(tk *Token, args []*term) *term {
var pos termPosition = posLeaf
if len(args) > 0 {
pos = posMultifix
}
return &term{
tk: *tk,
parent: nil,
children: args,
position: posLeaf,
position: pos,
priority: priValue,
evalFunc: evalFuncCall,
}
@@ -38,9 +44,9 @@ func newFuncCallTerm(tk *Token, args []*term) *term {
// return
// }
func evalFuncCall(ctx ExprContext, opTerm *term) (v any, err error) {
func evalFuncCall(ctx kern.ExprContext, opTerm *term) (v any, err error) {
name, _ := opTerm.tk.Value.(string)
v, err = CallFunctionByTerm(ctx, name, opTerm)
v, err = kern.CallFunctionByTerm(ctx, name, opTerm)
return
}
@@ -57,23 +63,23 @@ func newFuncDefTerm(tk *Token, args []*term) *term {
}
// -------- eval func def
func evalFuncDef(ctx ExprContext, opTerm *term) (v any, err error) {
func evalFuncDef(ctx kern.ExprContext, opTerm *term) (v any, err error) {
bodySpec := opTerm.value()
if expr, ok := bodySpec.(*ast); ok {
paramList := make([]ExprFuncParam, 0, len(opTerm.children))
if ast, ok := bodySpec.(*ast); ok {
paramList := make([]kern.ExprFuncParam, 0, len(opTerm.children))
for _, param := range opTerm.children {
var defValue any
flags := paramFlags(0)
if len(param.children) > 0 {
flags |= PfDefault
if defValue, err = param.children[0].compute(ctx); err != nil {
if defValue, err = param.children[0].Compute(ctx); err != nil {
return
}
}
info := NewFuncParamFlagDef(param.source(), flags, defValue)
info := NewFuncParamFlagDef(param.Source(), flags, defValue)
paramList = append(paramList, info)
}
v = newExprFunctor(expr, paramList, ctx)
v = newExprFunctor(ast, paramList, ctx)
} else {
err = errors.New("invalid function definition: the body specification must be an expression")
}