diff options
-rw-r--r-- | main.cpp | 11 | ||||
-rw-r--r-- | parser.cpp | 3 |
2 files changed, 10 insertions, 4 deletions
@@ -2,6 +2,7 @@ * FACULTAD DE CIENCIAS FÍSICO MATEMÁTICAS * Luis Sebastián Martínez Vega - LCC */ +#include <cstddef> #include <iterator> #include <ostream> #include <string> @@ -16,19 +17,20 @@ using std::string, std::cin, std::cout, std::getline, std::vector, std::begin, std::end, std::endl; -int main(){ +int main() { int counter = 1; string input; Parser parser; - Expression *tree, *simplified, *diff; + Expression *tree = NULL, *simplified = NULL, *diff = NULL; cout << ">> "; while(getline(cin, input)) { try { tree = parser.parse(input); } catch(const ParserException &e) { - cout << e.showMsg(); + cout << e.showMsg() << "\n"; cout << ">> "; + tree = NULL; continue; } @@ -40,6 +42,9 @@ int main(){ delete tree; delete simplified; delete diff; + tree = NULL; + simplified = NULL; + diff = NULL; ++counter; } @@ -10,7 +10,8 @@ using std::string, std::stoi; void Parser::panic() { for(auto ptr = tree_queue.begin(); ptr != tree_queue.end(); ++ptr) delete *ptr; - + + tree_queue.clear(); throw ParserException("Sintaxis incorrecta."); } |