summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-24 18:48:05 +0300
committerPaul Buetow <paul@buetow.org>2026-05-24 18:48:05 +0300
commit4188db97bcb771c1c8790ddbac2db3f9ee8884c3 (patch)
tree493e88ccd30232dc7b5105b0067764183721511c
parenta03e4511536a3cdafb51e187aa3bb9df764e8fec (diff)
fix(rpn): define OperatorRegistryProvider interface to fix DIP violation (task nk)
-rw-r--r--internal/rpn/operations_interfaces.go9
-rw-r--r--internal/rpn/rpn_state.go2
2 files changed, 10 insertions, 1 deletions
diff --git a/internal/rpn/operations_interfaces.go b/internal/rpn/operations_interfaces.go
index e659644..f317f8a 100644
--- a/internal/rpn/operations_interfaces.go
+++ b/internal/rpn/operations_interfaces.go
@@ -152,6 +152,15 @@ type OperationsProvider interface {
CustomMetricManager
}
+// OperatorRegistryProvider defines the methods RPN needs from the operator registry.
+// RPN depends on this interface (DIP) rather than the concrete *OperatorRegistry type.
+type OperatorRegistryProvider interface {
+ IsStandardOperator(token string) bool
+ IsHyperOperator(token string) bool
+ HandleStandardOperator(stack *Stack, token string) (string, bool, error)
+ HandleHyperOperator(stack *Stack, token string) (string, bool, error)
+}
+
// Operator implementations are split across focused sub-interfaces
// (ArithmeticOperator, LogarithmicOperator, MetricOperator, BooleanOperator,
// HyperOperator, StackOperator, VariableOperator, ConstantOperator,
diff --git a/internal/rpn/rpn_state.go b/internal/rpn/rpn_state.go
index a42372a..f2cc4ed 100644
--- a/internal/rpn/rpn_state.go
+++ b/internal/rpn/rpn_state.go
@@ -15,7 +15,7 @@ type RPN struct {
vars VariableStore
consts ConstantsProvider
ops OperationsProvider
- opRegistry *OperatorRegistry
+ opRegistry OperatorRegistryProvider
maxStack int
currentStack *Stack
}