summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-26 09:46:57 +0200
committerPaul Buetow <paul@buetow.org>2026-03-26 09:46:57 +0200
commit1d2c7f027204896c382983053c151debd0d35285 (patch)
treec76253daad6d75b2d3149a165e955e44f3657d5e
parentb0f6b552ed0690e3fad98e9771bbd6a47fbc2e37 (diff)
refactor: remove unused StackOperations struct
This struct provided stack manipulation operator implementations but was never used in the codebase. All stack operations are implemented directly in the Operations struct in operations.go.
-rw-r--r--internal/rpn/stack.go68
1 files changed, 0 insertions, 68 deletions
diff --git a/internal/rpn/stack.go b/internal/rpn/stack.go
deleted file mode 100644
index a956902..0000000
--- a/internal/rpn/stack.go
+++ /dev/null
@@ -1,68 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright (c) 2026 Paul Buetow
-
-package rpn
-
-import (
- "fmt"
-)
-
-// StackOperations provides stack manipulation operator implementations.
-type StackOperations struct {
-}
-
-// NewStackOperations creates a new StackOperations instance.
-func NewStackOperations() *StackOperations {
- return &StackOperations{}
-}
-
-// Dup duplicates the top stack value.
-func (o *StackOperations) Dup(stack *Stack) error {
- val, err := stack.Peek()
- if err != nil {
- return fmt.Errorf("insufficient operands for dup: %w", err)
- }
- stack.Push(val)
- return nil
-}
-
-// Swap swaps the top two stack values.
-func (o *StackOperations) Swap(stack *Stack) error {
- b, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for swap: %w", err)
- }
-
- a, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for swap: %w", err)
- }
-
- // Push in swapped order
- stack.Push(b)
- stack.Push(a)
- return nil
-}
-
-// Pop removes the top stack value.
-func (o *StackOperations) Pop(stack *Stack) error {
- _, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for pop: %w", err)
- }
- return nil
-}
-
-// Show returns the current stack state as a string without modifying it.
-func (o *StackOperations) Show(stack *Stack) (string, error) {
- if stack.Len() == 0 {
- return "", fmt.Errorf("empty stack")
- }
- // For now, just return the top value as a string
- // In a full implementation, this would show the entire stack
- val, err := stack.Peek()
- if err != nil {
- return "", err
- }
- return val.String(), nil
-}