diff options
author | Morgan Deters <mdeters@gmail.com> | 2009-11-18 22:02:11 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2009-11-18 22:02:11 +0000 |
commit | 394791604a62e19763a8a45328bc5177d91fabf9 (patch) | |
tree | 29027c84c0285da33bac6c5d1366635b9e4db1bc /src/main/main.cpp | |
parent | 477e97cd81afe4b86eea47e9abe6311fc22299fc (diff) |
work on exprs, driver, util
Diffstat (limited to 'src/main/main.cpp')
-rw-r--r-- | src/main/main.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/main/main.cpp b/src/main/main.cpp new file mode 100644 index 000000000..4850d475f --- /dev/null +++ b/src/main/main.cpp @@ -0,0 +1,68 @@ +#include <cstdio> +#include <cstdlib> +#include <cerrno> +#include <new> +#include <exception> +#include <unistd.h> +#include <string.h> +#include <stdint.h> +#include <time.h> + +#include "config.h" +#include "main.h" +#include "usage.h" + +using namespace std; +using namespace CVC4; +using namespace CVC4::Main; + +int main(int argc, char *argv[]) { + struct Options opts; + + try { + cvc4_init(); + + int firstArgIndex = parseOptions(argc, argv, &opts); + + FILE *infile; + + if(firstArgIndex >= argc) { + infile = stdin; + } else if(argc > firstArgIndex + 1) { + throw new Exception("Too many input files specified."); + } else { + infile = fopen(argv[firstArgIndex], "r"); + if(!infile) { + throw new Exception(string("Could not open input file `") + argv[firstArgIndex] + "' for reading: " + strerror(errno)); + exit(1); + } + } + } catch(CVC4::Main::OptionException* e) { + if(opts.smtcomp_mode) { + printf("unknown"); + fflush(stdout); + } + fprintf(stderr, "CVC4 Error:\n%s\n\n", e->toString().c_str()); + printf(usage, opts.binary_name.c_str()); + exit(1); + } catch(CVC4::Exception* e) { + if(opts.smtcomp_mode) { + printf("unknown"); + fflush(stdout); + } + fprintf(stderr, "CVC4 Error:\n%s\n", e->toString().c_str()); + exit(1); + } catch(bad_alloc) { + if(opts.smtcomp_mode) { + printf("unknown"); + fflush(stdout); + } + fprintf(stderr, "CVC4 ran out of memory.\n"); + exit(1); + } catch(...) { + fprintf(stderr, "CVC4 threw an exception of unknown type.\n"); + exit(1); + } + + return 0; +} |