Interesting, this is basically a very simple interpreter with a REPL. You should look into interpreters if this is something you enjoyed creating, there are many efficient and simple algorithms you could use to make this program a lot simpler and even more advanced too. For instance, recursive descent parsing, and the shunting yard algorithm.