moved scanner sources to package 'scan'
This commit is contained in:
+12
-11
@@ -8,24 +8,25 @@ import (
|
||||
"fmt"
|
||||
|
||||
"git.portale-stac.it/go-pkg/expr/kern"
|
||||
"git.portale-stac.it/go-pkg/expr/scan"
|
||||
)
|
||||
|
||||
// -------- variable term
|
||||
func newVarTerm(tk *Token) *term {
|
||||
t := &term{
|
||||
tk: *tk,
|
||||
parent: nil,
|
||||
children: nil,
|
||||
position: posLeaf,
|
||||
priority: priValue,
|
||||
evalFunc: evalVar,
|
||||
func newVarTerm(tk *scan.Token) *scan.Term {
|
||||
t := &scan.Term{
|
||||
Tk: *tk,
|
||||
Parent: nil,
|
||||
Children: nil,
|
||||
Position: scan.PosLeaf,
|
||||
Priority: scan.PriValue,
|
||||
EvalFunc: evalVar,
|
||||
}
|
||||
t.tk.Sym = SymVariable
|
||||
t.Tk.Sym = scan.SymVariable
|
||||
return t
|
||||
}
|
||||
|
||||
// -------- eval func
|
||||
func evalVar(ctx kern.ExprContext, opTerm *term) (v any, err error) {
|
||||
func evalVar(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
|
||||
var exists bool
|
||||
name := opTerm.Source()
|
||||
if v, exists = ctx.GetVar(name); !exists {
|
||||
@@ -40,5 +41,5 @@ func evalVar(ctx kern.ExprContext, opTerm *term) (v any, err error) {
|
||||
|
||||
// init
|
||||
func init() {
|
||||
registerTermConstructor(SymIdentifier, newVarTerm)
|
||||
scan.RegisterTermConstructor(scan.SymIdentifier, newVarTerm)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user