moved scanner sources to package 'scan'
This commit is contained in:
+14
-13
@@ -6,29 +6,30 @@ package expr
|
||||
|
||||
import (
|
||||
"git.portale-stac.it/go-pkg/expr/kern"
|
||||
"git.portale-stac.it/go-pkg/expr/scan"
|
||||
)
|
||||
|
||||
//-------- context term
|
||||
|
||||
func newContextTerm(tk *Token) (inst *term) {
|
||||
return &term{
|
||||
tk: *tk,
|
||||
children: make([]*term, 0, 1),
|
||||
position: posPrefix,
|
||||
priority: priIncDec,
|
||||
evalFunc: evalContextValue,
|
||||
func newContextTerm(tk *scan.Token) (inst *scan.Term) {
|
||||
return &scan.Term{
|
||||
Tk: *tk,
|
||||
Children: make([]*scan.Term, 0, 1),
|
||||
Position: scan.PosPrefix,
|
||||
Priority: scan.PriIncDec,
|
||||
EvalFunc: evalContextValue,
|
||||
}
|
||||
}
|
||||
|
||||
func evalContextValue(ctx kern.ExprContext, opTerm *term) (v any, err error) {
|
||||
func evalContextValue(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
|
||||
var childValue any
|
||||
|
||||
var sourceCtx kern.ExprContext
|
||||
if len(opTerm.children) == 0 {
|
||||
if len(opTerm.Children) == 0 {
|
||||
sourceCtx = ctx
|
||||
} else if opTerm.children[0].symbol() == SymVariable && opTerm.children[0].Source() == "global" {
|
||||
} else if opTerm.Children[0].Symbol() == scan.SymVariable && opTerm.Children[0].Source() == "global" {
|
||||
sourceCtx = ctx.GetGlobal()
|
||||
} else if childValue, err = opTerm.evalPrefix(ctx); err == nil {
|
||||
} else if childValue, err = opTerm.EvalPrefix(ctx); err == nil {
|
||||
if dc, ok := childValue.(*dataCursor); ok {
|
||||
sourceCtx = dc.ctx
|
||||
}
|
||||
@@ -53,12 +54,12 @@ func evalContextValue(ctx kern.ExprContext, opTerm *term) (v any, err error) {
|
||||
v = d
|
||||
}
|
||||
} else {
|
||||
err = opTerm.errIncompatiblePrefixPostfixType(childValue)
|
||||
err = opTerm.ErrIncompatiblePrefixPostfixType(childValue)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// init
|
||||
func init() {
|
||||
registerTermConstructor(SymDoubleDollar, newContextTerm)
|
||||
scan.RegisterTermConstructor(scan.SymDoubleDollar, newContextTerm)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user