From a838361ea84a9f5f163faeed4d97baf41d22ed9d Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Sat, 4 May 2024 00:30:35 +0200 Subject: [PATCH] operator-dot.go: specific *dataCursor case replaced by general ExtIterator --- operator-dot.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/operator-dot.go b/operator-dot.go index a3b67f9..f75837e 100644 --- a/operator-dot.go +++ b/operator-dot.go @@ -65,17 +65,27 @@ func evalDot(ctx ExprContext, self *term) (v any, err error) { err = fmt.Errorf("key %v does not belong to the dictionary", rightValue) } } - case *dataCursor: + // case *dataCursor: + // if indexTerm.symbol() == SymIdentifier { + // opName := indexTerm.source() + // if opName == resetName { + // _, err = unboxedValue.Reset() + // } else if opName == cleanName { + // _, err = unboxedValue.Clean() + // } else { + // err = indexTerm.Errorf("iterators do not support command %q", opName) + // } + // v = err == nil + // } + case ExtIterator: if indexTerm.symbol() == SymIdentifier { opName := indexTerm.source() - if opName == resetName { - err = unboxedValue.Reset() - } else if opName == cleanName { - err = unboxedValue.Clean() + if unboxedValue.HasOperation(opName) { + v, err = unboxedValue.CallOperation(opName, []any{}) } else { - err = indexTerm.Errorf("iterators do not support command %q", opName) + err = indexTerm.Errorf("this iterator do not support the %q command", opName) + v = false } - v = err == nil } default: err = self.errIncompatibleTypes(leftValue, rightValue)