33 lines
650 B
Go
33 lines
650 B
Go
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
|
// All rights reserved.
|
|
|
|
// operator-but.go
|
|
package expr
|
|
|
|
import (
|
|
"git.portale-stac.it/go-pkg/expr/kern"
|
|
"git.portale-stac.it/go-pkg/expr/scan"
|
|
)
|
|
|
|
//-------- but term
|
|
|
|
func newButTerm(tk *scan.Token) (inst *scan.Term) {
|
|
return &scan.Term{
|
|
Tk: *tk,
|
|
Children: make([]*scan.Term, 0, 2),
|
|
Position: scan.PosInfix,
|
|
Priority: scan.PriBut,
|
|
EvalFunc: evalBut,
|
|
}
|
|
}
|
|
|
|
func evalBut(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
|
|
_, v, err = opTerm.EvalInfix(ctx)
|
|
return
|
|
}
|
|
|
|
// init
|
|
func init() {
|
|
scan.RegisterTermConstructor(scan.SymKwBut, newButTerm)
|
|
}
|