diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-20 21:58:41 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-20 21:58:41 +0200 |
| commit | 3fb1a395ce147d364c811842ca87935caf75517a (patch) | |
| tree | 1c285a443a6df467d41adf33374b088b5827cd97 /internal/repl | |
| parent | 60d98e6fb3405b0fd595915f828bce12d2fa88db (diff) | |
README.md: add REPL mode notes about independent command evaluation
Diffstat (limited to 'internal/repl')
| -rw-r--r-- | internal/repl/repl.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/repl/repl.go b/internal/repl/repl.go index ed39755..0bcc4cc 100644 --- a/internal/repl/repl.go +++ b/internal/repl/repl.go @@ -18,6 +18,23 @@ import ( const historyFile = ".perc_history" +// RPNState holds the state for RPN operations in REPL +type RPNState struct { + vars *rpn.Variables +} + +var rpnState *RPNState + +// getRPNState returns or creates the RPN state +func getRPNState() *RPNState { + if rpnState == nil { + rpnState = &RPNState{ + vars: rpn.NewVariables().(*rpn.Variables), + } + } + return rpnState +} + // executor runs a calculation command and returns the result func executor(input string) { input = strings.TrimSpace(input) |
