Parent directory

AGENTS.md

1376 bytes

RPN Calculator

Structure

  • main.go composes the calculator and terminal UI.
  • rpn/lexer.go tokenizes calculator input.
  • rpn/rpn.go is terminal-free: it evaluates tokens against the stack and exposes calculator events and stack snapshots.
  • rpn/stack.go, rpn/token.go, and rpn/parser.go define the stack, token types, and input cursor.
  • rpn/rpn_test.go covers calculator evaluation, events, and stack snapshots.
  • tui/application.go renders the tview interface and owns terminal input, layout, status messages, help, and exit behavior.

Local Development

Run the following from the repository root:

go test ./...
go vet ./...
golangci-lint run

Gotchas

  • Do not run go run . or the compiled REPL from an agent loop. It waits indefinitely for terminal input. Use the compile, test, vet, and lint commands above for automated verification; test the REPL manually in a real terminal when necessary.
  • The terminal UI uses github.com/rivo/tview. Do not combine it with readline or direct ANSI cursor handling: tview owns raw terminal input and rendering.
  • Keep rpn independent of tview and terminal output. Exchange calculator events and copied stack snapshots through its public API instead.
  • golangci-lint is the project lint command. Error strings must begin with lowercase letters to satisfy its staticcheck configuration.