moved scanner sources to package 'scan'
This commit is contained in:
+13
-12
@@ -8,27 +8,28 @@ import (
|
||||
"fmt"
|
||||
|
||||
"git.portale-stac.it/go-pkg/expr/kern"
|
||||
"git.portale-stac.it/go-pkg/expr/scan"
|
||||
)
|
||||
|
||||
// -------- expr term
|
||||
func newExprTerm(root *term) *term {
|
||||
tk := NewValueToken(root.tk.row, root.tk.col, SymExpression, root.Source(), root)
|
||||
return &term{
|
||||
tk: *tk,
|
||||
parent: nil,
|
||||
children: nil,
|
||||
position: posLeaf,
|
||||
priority: priValue,
|
||||
evalFunc: evalExpr,
|
||||
func newExprTerm(root *scan.Term) *scan.Term {
|
||||
tk := scan.NewValueToken(root.Tk.Row(), root.Tk.Col(), scan.SymExpression, root.Source(), root)
|
||||
return &scan.Term{
|
||||
Tk: *tk,
|
||||
Parent: nil,
|
||||
Children: nil,
|
||||
Position: scan.PosLeaf,
|
||||
Priority: scan.PriValue,
|
||||
EvalFunc: evalExpr,
|
||||
}
|
||||
}
|
||||
|
||||
// -------- eval expr
|
||||
func evalExpr(ctx kern.ExprContext, opTerm *term) (v any, err error) {
|
||||
if ast, ok := opTerm.value().(*term); ok {
|
||||
func evalExpr(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
|
||||
if ast, ok := opTerm.Value().(*scan.Term); ok {
|
||||
v, err = ast.Compute(ctx)
|
||||
} else {
|
||||
err = fmt.Errorf("expression expected, got %T", opTerm.value())
|
||||
err = fmt.Errorf("expression expected, got %T", opTerm.Value())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user