The russian version of the task can be found in the repository.
In addition to basic arithmetic operations, such as plus-minus and multiply-divide, it is possible to calculate arithmetic expressions taking into account priorities, as well as some mathematical functions (sin, cos, logarithm, etc.). It is supported to use the variable x and plot the corresponding function.
s21
namespace.src/build
.dvi
target provides with doxygen style documentation.dist
target generates a zipped .tar file of archive for distribution.The Model-View-Controller (MVC) pattern is a scheme for separating application modules into three macro components: a model that contains the business logic, a view that is a UI form for interacting with the program, and a controller that modifies the model by user action.
The view
contains all the code associated with the program interface, while model
performs the calculation.
The calculation is based on Dijkstra's algorithm or the shunting-yard algorithm to translate expressions into reverse Polish notation to implement the calculation.
The Shunting-yard algorithm is stack-based. There are two text variables involved in the conversion: the input and the output string. The conversion process uses the stack to store operations not yet added to the output string. The conversion program sequentially reads each token from the input string and on each step does some actions based on which tokens have been read.
As long as there are unprocessed tokens in the input string, read the next token:
If the token is:
A number put it into the output queue
A function or a left parenthesis push it onto the stack
A function arguments separator (e.g. comma):
Operator (O1):
A right parenthesis:
If there are no more tokens left in the input string:
End.