diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-24 18:24:07 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-24 18:24:07 +0300 |
| commit | c4e1b3d3aa53d293307ddca6affff3715f3578c7 (patch) | |
| tree | 1501007fd06ead225675097f45f48153cd8c1879 | |
| parent | 950d103e714836da5667eff574dd51993dd1a204 (diff) | |
fix(rpn): consolidate extractVarName into rpn_parse.go (task 6k)
| -rw-r--r-- | internal/rpn/operations_variables.go | 14 | ||||
| -rw-r--r-- | internal/rpn/rpn_parse.go | 13 |
2 files changed, 13 insertions, 14 deletions
diff --git a/internal/rpn/operations_variables.go b/internal/rpn/operations_variables.go index 9f60133..d1b07eb 100644 --- a/internal/rpn/operations_variables.go +++ b/internal/rpn/operations_variables.go @@ -97,20 +97,6 @@ func (o *Operations) ClearVariables() { o.vars.ClearVariables() } -// extractVarName extracts a variable name from a StackValue. -// Symbols use their internal name, StringNums use their string value, -// and all other types fall back to String(). -func extractVarName(val StackValue) string { - switch v := val.(type) { - case *Symbol: - return v.Name() - case *StringNum: - return v.String() - default: - return val.String() - } -} - // AssignLeft assigns a value to a variable (for =: operator). // Stack order: value name =: (value on bottom, name on top). // This function pops name first (top of stack), then value. diff --git a/internal/rpn/rpn_parse.go b/internal/rpn/rpn_parse.go index 92292ae..51c64c7 100644 --- a/internal/rpn/rpn_parse.go +++ b/internal/rpn/rpn_parse.go @@ -405,6 +405,19 @@ func extractVariableName(token string) string { return token } +// extractVarName extracts a variable name from a StackValue. +// Handles Symbol and StringNum types, falls back to String(). +func extractVarName(val StackValue) string { + switch v := val.(type) { + case *Symbol: + return v.Name() + case *StringNum: + return v.String() + default: + return val.String() + } +} + // checkStackOverflow returns an error if the stack has reached the maximum size. func (r *RPN) checkStackOverflow(stack *Stack) error { if stack.Len() >= r.maxStack { |
