|
| 1 | +/*******************************************************************\ |
| 2 | +Module: Parse Options Module |
| 3 | +Author: Michael Tautschnig |
| 4 | +\*******************************************************************/ |
| 5 | + |
| 6 | +/// \file |
| 7 | +/// Main Module |
| 8 | + |
| 9 | +#include "goto_synthesizer_parse_options.h" |
| 10 | + |
| 11 | +#include <util/config.h> |
| 12 | +#include <util/exit_codes.h> |
| 13 | +#include <util/version.h> |
| 14 | + |
| 15 | +#include <goto-programs/read_goto_binary.h> |
| 16 | + |
| 17 | +#include <iostream> |
| 18 | + |
| 19 | +/// invoke main modules |
| 20 | +int goto_synthesizer_parse_optionst::doit() |
| 21 | +{ |
| 22 | + if(cmdline.isset("version")) |
| 23 | + { |
| 24 | + std::cout << CBMC_VERSION << '\n'; |
| 25 | + return CPROVER_EXIT_SUCCESS; |
| 26 | + } |
| 27 | + |
| 28 | + if(cmdline.args.size() != 1 && cmdline.args.size() != 2) |
| 29 | + { |
| 30 | + help(); |
| 31 | + return CPROVER_EXIT_USAGE_ERROR; |
| 32 | + } |
| 33 | + |
| 34 | + messaget::eval_verbosity( |
| 35 | + cmdline.get_value("verbosity"), messaget::M_STATISTICS, ui_message_handler); |
| 36 | + |
| 37 | + register_languages(); |
| 38 | + |
| 39 | + get_goto_program(); |
| 40 | + |
| 41 | + // TODO |
| 42 | + // Migrate synthesizer and tests from goto-instrument to goto-synthesizer |
| 43 | + |
| 44 | + help(); |
| 45 | + return CPROVER_EXIT_USAGE_ERROR; |
| 46 | +} |
| 47 | + |
| 48 | +void goto_synthesizer_parse_optionst::get_goto_program() |
| 49 | +{ |
| 50 | + log.status() << "Reading GOTO program from '" << cmdline.args[0] << "'" |
| 51 | + << messaget::eom; |
| 52 | + |
| 53 | + config.set(cmdline); |
| 54 | + |
| 55 | + auto result = read_goto_binary(cmdline.args[0], ui_message_handler); |
| 56 | + |
| 57 | + if(!result.has_value()) |
| 58 | + throw 0; |
| 59 | + |
| 60 | + goto_model = std::move(result.value()); |
| 61 | + |
| 62 | + config.set_from_symbol_table(goto_model.symbol_table); |
| 63 | +} |
| 64 | + |
| 65 | +/// display command line help |
| 66 | +void goto_synthesizer_parse_optionst::help() |
| 67 | +{ |
| 68 | + // clang-format off |
| 69 | + std::cout << '\n' << banner_string("Goto-synthesizer", CBMC_VERSION) << '\n' |
| 70 | + << align_center_with_border("Copyright (C) 2021") << '\n' |
| 71 | + << align_center_with_border("Qinheping Hu") << '\n' |
| 72 | + << align_center_with_border( "[email protected]") << '\n' |
| 73 | + << |
| 74 | + "\n" |
| 75 | + "Usage: Purpose:\n" |
| 76 | + "\n" |
| 77 | + " goto-synthesizer [-?] [-h] [--help] show help\n" |
| 78 | + " goto-synthesizer in out synthesize and apply loop invariants.\n" // NOLINT(*) |
| 79 | + "\n" |
| 80 | + "Main options:\n" |
| 81 | + "\n" |
| 82 | + "Other options:\n" |
| 83 | + " --version show version and exit\n" |
| 84 | + " --xml-ui use XML-formatted output\n" |
| 85 | + " --json-ui use JSON-formatted output\n" |
| 86 | + "\n"; |
| 87 | + // clang-format on |
| 88 | +} |
0 commit comments