// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com). // All rights reserved. // operator-post-inc.go package expr // -------- post increment term func newPostIncTerm(tk *Token) *term { return &term{ tk: *tk, parent: nil, children: make([]*term, 0, 1), position: posPostfix, priority: priPrePost, evalFunc: evalPostInc, } } func evalPostInc(ctx ExprContext, self *term) (v any, err error) { var childValue any if childValue, err = self.evalPrefix(ctx); err != nil { return } 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 { err = self.errIncompatibleType(childValue) } return } // init func init() { registerTermConstructor(SymDoublePlus, newPostIncTerm) }