turner-townsend-backend-ass.../README.md
2025-08-30 11:06:09 +01:00

46 lines
547 B
Markdown

# Fifth
A simple stack-based language called Fifth
## Usage
```shell
python fifth.py
```
### Commands
- `PUSH <n>` - push integer onto stack
- `POP` - remove top element
- `SWAP` - swap top two elements
- `DUP` - duplicate top element
- `+`, `-`, `*`, `/` - arithmetic operations
- `EXIT` - quit
### Example
```
stack is: []
PUSH 10
stack is: [10]
PUSH 5
stack is: [10, 5]
+
stack is: [15]
PUSH 45
stack is: [15, 45]
/
stack is: [3]
EXIT
```
## Tests
```bash
python -m pytest test_stack_calculator.py
```
## Requirements
- Python 3.10+