Starting Calculator Development (Calcx)
After finishing the last tiny project (port scanner), I now started working on my own calculator app in Rust which I (creatively) called calcx. By now, I was able to lay some ground work with general structs and making a very simple interactive “tui” using cliclack (through I did switch between tui libraries / crates quite a lot before settling for this one). The most current version of the source code can be found here: Github
Update:
A couple of days in and I have finally got token parsing sort of working. It's not really correct, yet. But the codebase is still surprisingly tidy and organized. I am genuinely shocked :D
Second-Update:
Well, I jinxed it. The codebase is everything but tidy. I am, however, quite content with the amount of features I was able to implement up until this point. By now, one is able to do actual basic calculations with the program (even with units; sort of). I'm not really sure which problem / feature I should tackle next, since there are quite a few possible next steps from my current state:
- Reorganizing the codebase to have everything in its own file
- Implementing well-formatted output of calculations (currently it's rather a debug message than anything else; this would probably not take too long to implement)
- Adding support for keywords like kilo, mega, etc
- Fixing already identified potential crashes (most obvious: –(1+2) crashes)
- Instead of crashing the program when it encounters an error, implement error messages and continue running
Despite everything else, I believe I should start with the task of reorganizing to lay the groundwork for all future additions.
Third-Update:
I guess I was quite productive:
- I've organized the folder structure into more, smaller files
- I've also added a display function (for later use, currently it's still horrible as it just returns the exponents of each unit in order, but it's good enough for now.
- Support for keywords for powers of 10 was added, you can now use kilo, nano, etc
- –(1+2) works, but no other crashes were fixed
- Some error handling has been done, but the previous system for the parsing into the tree was not yet restructured, only the eval function now returns a result enum.
Next ToDos:
- Figure out versioning (semantic versioning)
- Working on known crashes (e.g. (2)5 should return 10, but hangs; actually just fixed that one)
- Starting development on unit conversions?
- OR starting on functions (I don't know which seems more complex)
- Working with Variables
- Write documentation
Fourth Update:
I am now done with implementing all misc units (like volts, ohm, etc). I will now start to plan on how to implement keywords and parsing them. I guess I will have to implement this into the tree building. I might even be able to use the current logic for brackets in a similar way...