/* Main program of calculator example. Simply invoke the parser generated by bison, and then display the output. */ #include "expr.h" #include "token.h" #include /* Clunky: Declare the parse function generated from parser.bison */ // extern int yyparse(struct stmt *parser_result); extern int yyparse(); extern char *yytext; extern int yylex(); /* Clunky: Declare the result of the parser from parser.bison */ struct stmt *parser_result; int main(int argc, char *argv[]) { printf("Lab 6 Example Interpreter Compiler\n"); printf( "Enter an infix expression using the operators +-*/() ending with ;\n\n"); if (yyparse() == 0) { printf("Parse successful: \n"); if (parser_result != NULL) { stmt_print(parser_result); printf("\n"); printf("Running the program, results in: "); stmt_evaluate(parser_result); printf("\n"); } return 0; } else { printf("Parse failed!\n"); return 1; } }