#include <iostream>
+#include "expression.h"
-using namespace std;
+typedef enum
+{
+ PREFIX,
+ INFIX,
+ POSTFIX,
+ CALC,
+ QUIT
+} Commands;
+
+std::map<std::string, Commands> commands_string_map;
int main()
{
- string line;
- while ( getline(cin, line) )
+ std::string line;
+ std::cout << "Write expression: ";
+
+ std::getline(std::cin, line);
+ Expression e{line};
+
+ while (std::getline(std::cin, line))
{
- Expression e{line};
- cout << e.to_string() << endl
- << e.evaluate() << endl;
+ if (line == ":prefix")
+ {
+ std::cout << e.to_prefix_string() << std::endl;
+ }
+ else if (line == ":infix")
+ {
+ std::cout << e.to_infix_string() << std::endl;
+ }
+ else if (line == ":postfix")
+ {
+ std::cout << e.to_postfix_string() << std::endl;
+ }
+ else if (line == ":calc")
+ {
+ std::cout << "Value: " << e.evaluate() << std::endl;
+ }
+ else if (line == ":quit")
+ {
+ break;
+ }
+ else
+ {
+ Expression e{line};
+ }
}
return 0;
}