removed commented code

This commit is contained in:
Celestino Amoroso 2024-05-04 00:57:21 +02:00
parent 16557d70de
commit 7724cabdcc
5 changed files with 14 additions and 33 deletions

View File

@ -6,9 +6,7 @@ package expr
import (
"errors"
"fmt"
"io"
"strings"
)
const (
@ -39,19 +37,19 @@ func newDataCursor(ctx ExprContext, ds map[string]Functor) (dc *dataCursor) {
return
}
func mapToString(m map[string]Functor) string {
var sb strings.Builder
sb.WriteByte('{')
for key, _ := range m {
if sb.Len() > 1 {
sb.WriteString(fmt.Sprintf(", %q: func(){}", key))
} else {
sb.WriteString(fmt.Sprintf("%q: func(){}", key))
}
}
sb.WriteByte('}')
return sb.String()
}
// func mapToString(m map[string]Functor) string {
// var sb strings.Builder
// sb.WriteByte('{')
// for key, _ := range m {
// if sb.Len() > 1 {
// sb.WriteString(fmt.Sprintf(", %q: func(){}", key))
// } else {
// sb.WriteString(fmt.Sprintf("%q: func(){}", key))
// }
// }
// sb.WriteByte('}')
// return sb.String()
// }
func (dc *dataCursor) String() string {
return "$()"

View File

@ -91,8 +91,6 @@ func getDataSourceDict(ctx ExprContext, self *term, firstChildValue any) (ds map
}
err = fmt.Errorf("the data-source must provide a non-nil %q operator(s)", strings.Join(missingFields, ", "))
}
// } else {
// err = self.Errorf("the first param (data-source) of an iterator must be a dict, not a %T", value)
}
return
}

View File

@ -23,9 +23,7 @@ func evalIterValue(ctx ExprContext, self *term) (v any, err error) {
return
}
/*if dc, ok := childValue.(*dataCursor); ok {
v, err = dc.Current()
} else*/if it, ok := childValue.(Iterator); ok {
if it, ok := childValue.(Iterator); ok {
v, err = it.Current()
} else {
err = self.errIncompatibleType(childValue)

View File

@ -23,8 +23,6 @@ func evalPostInc(ctx ExprContext, self *term) (v any, err error) {
return
}
// if dc, ok := leftValue.(*dataCursor); ok {
// v, err = dc.Next()
if it, ok := childValue.(Iterator); ok {
v, err = it.Next()
} else if isInteger(childValue) && self.children[0].symbol() == SymIdentifier {

View File

@ -139,26 +139,15 @@ func (self *parser) parseList(scanner *scanner, allowVarRef bool) (subtree *term
}
func (self *parser) parseIterDef(scanner *scanner, allowVarRef bool) (subtree *term, err error) {
// var ds *term
tk := scanner.Previous()
args := make([]*term, 0)
lastSym := SymUnknown
//dsExpected := true
itemExpected := false
for lastSym != SymClosedRound && lastSym != SymEos {
var subTree *ast
if subTree, err = self.parseItem(scanner, allowVarRef, SymComma, SymClosedRound); err == nil {
if subTree.root != nil {
/* if dsExpected {
if sym := subTree.root.symbol(); sym == SymDict || sym == SymIdentifier {
ds = subTree.root
} else {
err = subTree.root.Errorf("data-source dictionary expected, got %q", subTree.root.source())
}
dsExpected = false
} else {*/
args = append(args, subTree.root)
// }
} else if itemExpected {
prev := scanner.Previous()
err = prev.Errorf("expected iterator argument, got %q", prev)