GCC Code Coverage Report
Directory: . Exec Total Coverage
File: build-coverage/src/options/printer_options.cpp Lines: 4 39 10.3 %
Date: 2021-09-15 Branches: 4 54 7.4 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Mathias Preiner, Aina Niemetz
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8
 * in the top-level source directory and their institutional affiliations.
9
 * All rights reserved.  See the file COPYING in the top-level source
10
 * directory for licensing information.
11
 * ****************************************************************************
12
 *
13
 * Option template for option modules.
14
 *
15
 * For each <module>_options.toml configuration file, mkoptions.py
16
 * expands this template and generates a <module>_options.cpp file.
17
 */
18
#include "options/printer_options.h"
19
20
#include <iostream>
21
22
#include "base/check.h"
23
#include "options/option_exception.h"
24
25
namespace cvc5::options {
26
27
// clang-format off
28
std::ostream& operator<<(std::ostream& os, ModelFormatMode mode)
29
{
30
  switch(mode)
31
  {
32
    case ModelFormatMode::DEFAULT: return os << "ModelFormatMode::DEFAULT";
33
    case ModelFormatMode::TABLE: return os << "ModelFormatMode::TABLE";
34
    default: Unreachable();
35
  }
36
  return os;
37
}
38
ModelFormatMode stringToModelFormatMode(const std::string& optarg)
39
{
40
  if (optarg == "default") return ModelFormatMode::DEFAULT;
41
  else if (optarg == "table") return ModelFormatMode::TABLE;
42
  else if (optarg == "help")
43
  {
44
    std::cerr << R"FOOBAR(
45
  Model format modes.
46
Available modes for --model-format are:
47
+ default
48
  Print model as expressions in the output language format.
49
+ table
50
  Print functional expressions over finite domains in a table format.
51
)FOOBAR";
52
    std::exit(1);
53
  }
54
  throw OptionException(std::string("unknown option for --model-format: `") +
55
                        optarg + "'.  Try --model-format=help.");
56
}
57
std::ostream& operator<<(std::ostream& os, PrintInstMode mode)
58
{
59
  switch(mode)
60
  {
61
    case PrintInstMode::LIST: return os << "PrintInstMode::LIST";
62
    case PrintInstMode::NUM: return os << "PrintInstMode::NUM";
63
    default: Unreachable();
64
  }
65
  return os;
66
}
67
3
PrintInstMode stringToPrintInstMode(const std::string& optarg)
68
{
69
3
  if (optarg == "list") return PrintInstMode::LIST;
70
3
  else if (optarg == "num") return PrintInstMode::NUM;
71
  else if (optarg == "help")
72
  {
73
    std::cerr << R"FOOBAR(
74
  Print format for printing instantiations.
75
Available modes for --print-inst are:
76
+ list (default)
77
  Print the list of instantiations per quantified formula, when non-empty.
78
+ num
79
  Print the total number of instantiations per quantified formula, when
80
  non-zero.
81
)FOOBAR";
82
    std::exit(1);
83
  }
84
  throw OptionException(std::string("unknown option for --print-inst: `") +
85
                        optarg + "'.  Try --print-inst=help.");
86
}
87
// clang-format on
88
89
namespace printer
90
{
91
// clang-format off
92
void setDefaultFlattenHOChains(Options& opts, bool value)
93
{
94
    if (!opts.printer.flattenHOChainsWasSetByUser) opts.printer.flattenHOChains = value;
95
}
96
void setDefaultModelFormatMode(Options& opts, ModelFormatMode value)
97
{
98
    if (!opts.printer.modelFormatModeWasSetByUser) opts.printer.modelFormatMode = value;
99
}
100
void setDefaultPrintInstMode(Options& opts, PrintInstMode value)
101
{
102
    if (!opts.printer.printInstModeWasSetByUser) opts.printer.printInstMode = value;
103
}
104
void setDefaultPrintInstFull(Options& opts, bool value)
105
{
106
    if (!opts.printer.printInstFullWasSetByUser) opts.printer.printInstFull = value;
107
}
108
// clang-format on
109
}
110
111
29577
}  // namespace cvc5::options