X-Git-Url: https://git.llucax.com/z.facultad/75.42/calculadora.git/blobdiff_plain/a8a23ec5e446b056284de0976cc1f3344ee8c6ad..8f5992a5811ef292022a3ca3ac293c231e2b065b:/parser_equation_test.c?ds=sidebyside diff --git a/parser_equation_test.c b/parser_equation_test.c index 0f6cae2..2d9be3e 100644 --- a/parser_equation_test.c +++ b/parser_equation_test.c @@ -34,12 +34,13 @@ */ int main(int argc, char* argv[]) { /* Declaración de variables. */ + int i; DLList* lista; ParseError* error; - if (argc != 2) { - fprintf(stderr, "Debe pasar la ecuación a evaluar como parámetro.\n"); - fprintf(stderr, "Ejemplo: %s 'b = 50 + h*2'\n", argv[0]); + if (argc < 2) { + fprintf(stderr, "Debe pasar ecuaciones a evaluar como parámetros.\n"); + fprintf(stderr, "Ejemplo: %s 'b = 50 + h*2' 'a = b+1\n", argv[0]); return EXIT_FAILURE; } @@ -55,14 +56,21 @@ int main(int argc, char* argv[]) { return EXIT_FAILURE; } - if (!parser_equation(argv[1], strlen(argv[1]), lista, error)) { - ParseError_print(error, stderr); - return EXIT_FAILURE; + for (i = 1; i < argc; i++) { + if (!parser_equation(argv[i], strlen(argv[i]), lista, error)) { + error->line = i; + ParseError_print(error, stderr); + } } DLList_equation_print(lista, stdout); - DLList_delete(lista); + DLList_equation_delete(lista); + + ParseError_delete(error); + + /* Veo si pierdo memoria. */ + memdebug_end(); return EXIT_SUCCESS; }