From 3fa0be1d2d3408b9fb2adbcf975fa49acd87e50d Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Tue, 26 Apr 2022 20:43:01 -0500 Subject: Añadido archivo main final. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/main.cpp b/main.cpp index c1ecd22..9328b1e 100644 --- a/main.cpp +++ b/main.cpp @@ -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 #include #include @@ -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; } -- cgit v1.2.3