I'm relatively new to programming. I have to create a calculator by parsing in user input. I managed to get that down. The catch is that users can create and assign values in-line. Examples: let x=23; let bigNumber=2^2*13; let foo= foo+23;
The user can then use those variables in expressions. Ex:1+2*6^2+(foo+2); How do I go about implementing this into a a calc using shunting yard?
I don't have code. I'm mainly going off of this http://www.technical-recipes.com/2011/a-mathematical-expression-parser-in-java-and-cpp/. I understand the code, but I wanna know how to go about the assigment. I think I can do something like let x=23 using maps. I can make "let" be a token that adds <x,23> to the map. Once assigned, I think I can also use it in an expression, i.e 2+4*foo by checking for operators, numbers, AND variables. But I dont know what to do for complicated assigments like the ones mentioned in the original post.
I'm going to try. I understand it and its open source so I thought about just modifying it and adding other operators since I don't have much time to finish the assigment. Either way, I'm lost when it comes to doing the assigment in-line(on the console). I think I would have to parse the right side of the = and do every operation(if any) to get the value. Am I going in the right direction?