-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.cpp
More file actions
31 lines (26 loc) · 837 Bytes
/
Copy pathrun.cpp
File metadata and controls
31 lines (26 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "run.hpp"
int main(int argc, char const *argv[])
{
std::string input;
setup_units();
while (1)
{
std::getline(std::cin, input);
if (input == "q" || input == "quit") break;
PrintFormat pf = PrintFormat::Default;
std::deque<Token> tokens = convert_to_rpn(tokenize(input, pf));
if (pf == PrintFormat::Commas)
{
std::locale commas(std::locale(), new comma_numpunct());
std::cout.imbue(commas);
}
else if (pf == PrintFormat::Spaces)
{
std::locale spaces(std::locale(), new space_numpunct());
std::cout.imbue(spaces);
}
Number res = simplify_rpn(tokens);
std::cout << " = " << res.val << " " << res.unit << std::endl;
}
return 0;
}