summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-11 21:34:01 +0300
committerPaul Buetow <paul@buetow.org>2026-04-11 21:34:01 +0300
commit8dbe047feaae419d9a5bdc34dfe9153e6704fd7f (patch)
tree1bd4e4b514f8a94919cec2b3a437a436b74f94e8
parent8b5b2f36de6a503b804d12315be027be841ede43 (diff)
Add constants lookup in rpn_parse.go handleOperator
- Added constants lookup after variable lookup in rpn_parse.go - Now constants like pi, e, phi, sqrt2, inf, nan work in RPN expressions
-rw-r--r--internal/rpn/rpn_parse.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/internal/rpn/rpn_parse.go b/internal/rpn/rpn_parse.go
index 6659c57..45531bb 100644
--- a/internal/rpn/rpn_parse.go
+++ b/internal/rpn/rpn_parse.go
@@ -465,6 +465,12 @@ func (r *RPN) handleOperator(stack *Stack, token string, tokenIndex int) (string
stack.Push(NewNumber(val, r.mode))
return "", nil
}
+ // Check if it's a constant reference (before operators)
+ if val, exists := r.consts.GetConstant(token); exists {
+ stack.Push(NewNumber(val, r.mode))
+ return "", nil
+ }
+
// Handle standard operators (common logic extracted for DRY)
// This must be done BEFORE pushing Symbol for unknown identifiers,