summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/repl/handlers.go9
-rw-r--r--internal/rpn/rpn_state.go12
2 files changed, 13 insertions, 8 deletions
diff --git a/internal/repl/handlers.go b/internal/repl/handlers.go
index 5e568a3..78f07dd 100644
--- a/internal/repl/handlers.go
+++ b/internal/repl/handlers.go
@@ -172,14 +172,7 @@ func (h *RPNHandler) Handle(repl *REPL, input string) (output string, handled bo
fields := strings.Fields(input)
if len(fields) == 1 {
op := strings.ToLower(fields[0])
- // Check if it's a known operator (standard or hyper)
- isStandardOp := op == "+" || op == "-" || op == "*" || op == "/" || op == "^" || op == "%" ||
- op == "dup" || op == "swap" || op == "pop" || op == "show" || op == "clear" || op == "vars" ||
- op == "lg" || op == "log" || op == "ln"
- isHyperOp := op == "[+]" || op == "[-]" || op == "[*]" || op == "[/]" || op == "[^]" || op == "[%]" ||
- op == "[lg]" || op == "[log]" || op == "[ln]"
-
- if isStandardOp || isHyperOp {
+ if repl.rpnState.rpnCalc.IsStandardOperator(op) || repl.rpnState.rpnCalc.IsHyperOperator(op) {
result, err := repl.rpnState.rpnCalc.EvalOperator(op)
if err != nil {
return "", true, err
diff --git a/internal/rpn/rpn_state.go b/internal/rpn/rpn_state.go
index 13cb5ca..a27f63a 100644
--- a/internal/rpn/rpn_state.go
+++ b/internal/rpn/rpn_state.go
@@ -110,3 +110,15 @@ func (r *RPN) GetPrefixMode() PrefixMode {
defer r.mu.RUnlock()
return r.ops.GetPrefixMode()
}
+
+// IsStandardOperator checks if a token is a registered standard operator.
+// Delegates to the operator registry.
+func (r *RPN) IsStandardOperator(token string) bool {
+ return r.opRegistry.IsStandardOperator(token)
+}
+
+// IsHyperOperator checks if a token is a registered hyper operator.
+// Delegates to the operator registry.
+func (r *RPN) IsHyperOperator(token string) bool {
+ return r.opRegistry.IsHyperOperator(token)
+}