int main(int argc, char *argv[]) { char *filename; int32_t code; double time, mem_used; if (argc > 2) { fprintf(stderr, "Usage: %s <filename>\n", argv[0]); exit(YICES_EXIT_USAGE); } if (argc == 2) { // read from file interactive = false; filename = argv[1]; if (init_smt2_file_lexer(&lexer, filename) < 0) { perror(filename); exit(YICES_EXIT_FILE_NOT_FOUND); } } else { // read from stdin interactive = true; init_smt2_stdin_lexer(&lexer); } yices_init(); init_smt2(true, 0, interactive); init_smt2_tstack(&stack); init_parser(&parser, &lexer, &stack); // disable SMT2_CHECK_SAT/PUSH/POP/GET_VALUE tstack_add_op(&stack, SMT2_CHECK_SAT, false, eval_smt2_skip, check_smt2_skip); tstack_add_op(&stack, SMT2_PUSH, false, eval_smt2_skip, check_smt2_skip); tstack_add_op(&stack, SMT2_POP, false, eval_smt2_skip, check_smt2_skip); tstack_add_op(&stack, SMT2_GET_VALUE, false, eval_smt2_skip, check_smt2_skip); // smt2_set_verbosity(100); while (smt2_active()) { if (interactive) { fputs("smt2> ", stdout); fflush(stdout); } code = parse_smt2_command(&parser); if (code < 0) { // syntax error if (interactive) { flush_lexer(&lexer); } else { break; // exit } } fflush(stdout); } // statistics time = get_cpu_time(); mem_used = mem_size() / (1024 * 1024); printf("\nRun time: %.4f s\n", time); printf("Memory used: %.2f MB\n\n", mem_used); fflush(stdout); delete_parser(&parser); close_lexer(&lexer); delete_tstack(&stack); delete_smt2(); yices_exit(); return YICES_EXIT_SUCCESS; }
int main(int argc, char *argv[]) { bool interactive; int32_t code; FILE *dump; double memused; process_command_line(argc, argv); yices_init(); init_tstack(&stack, NUM_BASE_OPCODES); interactive = false; if (input_filename == NULL) { init_yices_stdin_lexer(&lexer); interactive = true; } else { if (init_yices_file_lexer(&lexer, input_filename) < 0) { perror(input_filename); exit(YICES_EXIT_FILE_NOT_FOUND); } } init_parser(&parser, &lexer, &stack); while (current_token(&lexer) != TK_EOS) { if (interactive) { printf("yices> "); fflush(stdout); } code = parse_yices_command(&parser, stderr); if (code < 0) { flush_lexer(&lexer); } } delete_parser(&parser); close_lexer(&lexer); delete_tstack(&stack); memused = mem_size() / (1024 * 1024); if (memused > 0) { fprintf(stderr, "Memory used: %.2f MB\n", memused); } if (dump_requested) { if (dump_filename == NULL) { dump = stdout; } else { dump = fopen(dump_filename, "w"); if (dump == NULL) { perror(dump_filename); exit(YICES_EXIT_FILE_NOT_FOUND); } } fprintf(dump, "\n==== ALL TYPES ====\n"); print_type_table(dump, __yices_globals.types); fflush(dump); fprintf(dump, "\n==== ALL TERMS ====\n"); print_term_table(dump, __yices_globals.terms); fflush(dump); if (dump_filename != NULL) { if (fclose(dump) != 0) { fprintf(stderr, "Error while closing dump file: "); perror(dump_filename); } } } yices_exit(); return 0; }