diff options
-rw-r--r-- | main.cpp | 37 |
1 files changed, 24 insertions, 13 deletions
@@ -1,3 +1,7 @@ +/* PIA - Lenguajes Modernos de Programación + * FACULTAD DE CIENCIAS FÍSICO MATEMÁTICAS + * Luis Sebastián Martínez Vega - LCC */ + #include <iterator> #include <ostream> #include <string> @@ -13,26 +17,33 @@ using std::string, std::cin, std::cout, std::getline, std::vector, std::begin, std::end, std::endl; int main(){ + int counter = 1; string input; Parser parser; - Expression *tree; - Expression *simplified = NULL; - getline(cin, input); + Expression *tree, *simplified, *diff; - try { - tree = parser.parse(input); - cout << tree->getRepr() << '\n'; - } catch(const ParserException &e) { - cout << e.showMsg() << endl; - tree = NULL; - } + cout << ">> "; + while(getline(cin, input)) { + try { + tree = parser.parse(input); + } catch(const ParserException &e) { + cout << e.showMsg(); + cout << ">> "; + continue; + } + + diff = deriv(tree); + simplified = simplify(diff); + cout << "OUT " << counter << ": " << simplified->getRepr() << "\n"; + cout << ">> "; - if(tree != NULL) { - simplified = simplify(tree); - cout << simplified->getRepr() << endl; delete tree; delete simplified; + delete diff; + ++counter; } + + cout << "Adiós!\n" << endl; return 0; } |