From e463bd61d81587a2d034b7bf40e08d0e66d156c8 Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Sat, 4 May 2024 00:39:22 +0200 Subject: [PATCH] operator-post-inc.go: now operates on Iterator instead of *dataCursor --- operator-post-inc.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/operator-post-inc.go b/operator-post-inc.go index 8413d30..0def83e 100644 --- a/operator-post-inc.go +++ b/operator-post-inc.go @@ -18,19 +18,21 @@ func newPostIncTerm(tk *Token) *term { } func evalPostInc(ctx ExprContext, self *term) (v any, err error) { - var leftValue any - if leftValue, err = self.evalPrefix(ctx); err != nil { + var childValue any + if childValue, err = self.evalPrefix(ctx); err != nil { return } - if dc, ok := leftValue.(*dataCursor); ok { - v, err = dc.Next() - } else if isInteger(leftValue) && self.children[0].symbol() == SymIdentifier { - v = leftValue - i, _ := leftValue.(int64) + // 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 { + v = childValue + i, _ := childValue.(int64) ctx.SetVar(self.children[0].source(), i+1) } else { - self.errIncompatibleType(leftValue) + err = self.errIncompatibleType(childValue) } return }