#include "helper.h" int _process_input(struct string *input) { struct lexer *lexer = lexer_new(input); if (!lexer) { errx(BAD_GRAMMAR, "main: unable to create lexer."); } enum parser_state status = OK; struct ast *ast = NULL; int r = SHELL_TRUE; do { ast_free(ast); ast = parse(lexer, &status); if (status == ERROR) { errx(BAD_GRAMMAR, "main: parse failed."); } if (env_get("PRETTY_PRINT") != NULL) { pretty_print(ast); } if (ast) { r = eval_ast(ast); } } while (ast != NULL && status != ERROR); if (status == ERROR) { ast_free(ast); } string_free(lexer->input); lexer_free(lexer); return r; }