2024-01-05 12:04
BullseyeCoverage 9.6.4
expr/ main.cpp
1 // Sample program to evaluate C++ expressions 2 3 #include <iostream> 4 #include <string> 5 #include "Lexer.h" 6 #include "Parser.h" 7 8 int main(int argc, char *argv[]) 9 { 10 try { 11 Lexer::unitTest(); 12 Parser::unitTest(); 13 std::string line; 14 if (argc > 1) { 15 for (int i = 1; i < argc; i++) { 16 line += argv[i]; 17 line += " "; 18 } 19 } else { 20 std::cout << "Enter an expression\n"; 21 std::getline(std::cin, line); 22 } 23 Parser parser(line.c_str()); 24 std::cout << parser.expression() << std::endl; 25 } 26 catch (const char *s) { 27 std::cerr << s; 28 } 29 return 0; 30 }