For the primary four mixed operation of the software design, through the analysis of design requirements, I think for this software in the future to facilitate the expansion of functionality, you can use the last semester of the "compilation Principle" in the lesson of the LL1 grammar analysis and guidance translation algorithm to achieve. The benefits of doing this include the following points:
1. Because LL1 guidance translation is a mature and reliable technology, and its recursive descent algorithm is easy to adapt to the calculation algorithm;
2. We have a systematic approach to obtain more complex expressions of the LL1 grammar, it is easy to generate a rich form of formulas;
3. Due to the problem of operation priority in four mixed operation, it is very convenient to implement the function of computation expression by using LL1 Analyzer.
4. When the user needs to give a problem solving process rather than just an answer, the LL1 Analyzer can provide a correct process of solving the problem (can be LL1-guided translation of the generation of four to rewrite the calculation process).
Of course, there are some problems that need to be solved in the implementation, such as controlling the length of the calculation, avoiding redundant parentheses in the calculation, avoiding the calculation of the non-operator, avoiding meaningless formulas and so on.
At the moment, my Version 1.00 has implemented the ability to use the rewritten LL1 parser to generate a formula and get the answer at the same time, but it also has some of these problems. After all, the 1.00 version of the program is very rough, then I will analyze and resolve one by one, and then release Version 1.01.
Mixed operation Generator 1.00 debug based on LL1 grammar:
Software Engineering Learning Elementary School four mixed operation the design idea and thoughts of Version 1.00