From cd74d811d257d5579fbe974abbd6ad39a751d508 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 23 May 2026 23:56:14 +0300 Subject: docs(rpn): fix misleading comments in rpn_ops.go - EvalOperator: replace incorrect example ("1 2 +" then "+") with one matching the actual test ("1 2 3 +" then "+") since + requires two operands and the stack after "1 2 +" only has one value - executeOperator: update comment to list all three callers (handleOperator, ResultStack, EvalOperator) instead of just two --- internal/rpn/rpn_ops.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/rpn/rpn_ops.go b/internal/rpn/rpn_ops.go index 0c46576..5f0863a 100644 --- a/internal/rpn/rpn_ops.go +++ b/internal/rpn/rpn_ops.go @@ -72,7 +72,8 @@ func (r *RPN) ResultStack(tokens []string) (string, error) { } // EvalOperator evaluates a single operator on the current stack state. -// This allows incremental RPN operations like: "1 2 +" then "+". +// This allows incremental RPN operations, e.g., after ParseAndEvaluate("1 2 3 +") leaves +// the stack with [1, 5], calling EvalOperator("+") produces "6". func (r *RPN) EvalOperator(op string) (string, error) { if r.currentStack == nil { r.currentStack = NewStack() @@ -97,7 +98,7 @@ func (r *RPN) EvalOperator(op string) (string, error) { } // executeOperator handles operator execution (standard or hyper) and returns (result string, handled bool, error error). -// This is a helper to avoid code duplication between handleOperator and EvalOperator. +// This is a shared helper used by handleOperator, ResultStack, and EvalOperator. func (r *RPN) executeOperator(stack *Stack, token string) (string, bool, error) { // Check for hyperoperators first if r.opRegistry.IsHyperOperator(token) { -- cgit v1.2.3