Simple calculator -- code review
I just put together this simple integer calculator and I'm hoping I can get a few honest opinions of it (if reviews are favorable I might continue developing it :)) from the adoring public. Feel free to critique the code flow, user interface etc.
- Expression-style input (parentheses and precedence)
- Bignum support
Design and implementation notes:
- I would have posted the code inline, but it's >500 lines long and vB might not like it.
- I used gotos for the error handling mechanism, not exceptions. However the code should (hopefully) be as easy to follow.
- You need GMP to build. Tested on GMP 4.1.2.
- The code isn't very structured and a largely disproportionate amount is lumped in main().
- It will only handle integers and [+-*/%()] operations, but I've tried to make it versatile and capable of ignoring small errors if they do not affect the calculations.
- If you really want to know, it converts all expressions to postfix using the shunting yard algorithm and uses RPN for evaluation.
- Hope a kind soul will check if this builds on non-Windows platforms.
- I used C <stdio.h> because MinGW seems to have tendencies to bloat executables using C++ streams by a substantial amount.
Thanks in advance.