GCC Code Coverage Report
Directory: . Exec Total Coverage
File: build-coverage/src/options/printer_options.cpp Lines: 5 57 8.8 %
Date: 2021-08-14 Branches: 4 56 7.1 %

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
// clang-format off
26
namespace cvc5::options {
27
28
std::ostream& operator<<(std::ostream& os, ModelFormatMode mode)
29
{
30
  switch(mode) {
31
    case ModelFormatMode::DEFAULT:
32
      return os << "ModelFormatMode::DEFAULT";
33
    case ModelFormatMode::TABLE:
34
      return os << "ModelFormatMode::TABLE";
35
    default:
36
      Unreachable();
37
  }
38
  return os;
39
}
40
ModelFormatMode stringToModelFormatMode(const std::string& optarg)
41
{
42
  if (optarg == "default")
43
  {
44
    return ModelFormatMode::DEFAULT;
45
  }
46
  else if (optarg == "table")
47
  {
48
    return ModelFormatMode::TABLE;
49
  }
50
  else if (optarg == "help")
51
  {
52
    std::cerr << "Model format modes.\n"
53
         "Available modes for --model-format are:\n"
54
         "+ default\n"
55
         "  Print model as expressions in the output language format.\n"
56
         "+ table\n"
57
         "  Print functional expressions over finite domains in a table format.\n";
58
    std::exit(1);
59
  }
60
  throw OptionException(std::string("unknown option for --model-format: `") +
61
                        optarg + "'.  Try --model-format=help.");
62
}
63
std::ostream& operator<<(std::ostream& os, PrintInstMode mode)
64
{
65
  switch(mode) {
66
    case PrintInstMode::LIST:
67
      return os << "PrintInstMode::LIST";
68
    case PrintInstMode::NUM:
69
      return os << "PrintInstMode::NUM";
70
    default:
71
      Unreachable();
72
  }
73
  return os;
74
}
75
3
PrintInstMode stringToPrintInstMode(const std::string& optarg)
76
{
77
3
  if (optarg == "list")
78
  {
79
    return PrintInstMode::LIST;
80
  }
81
3
  else if (optarg == "num")
82
  {
83
3
    return PrintInstMode::NUM;
84
  }
85
  else if (optarg == "help")
86
  {
87
    std::cerr << "Print format for printing instantiations.\n"
88
         "Available modes for --print-inst are:\n"
89
         "+ list (default)\n"
90
         "  Print the list of instantiations per quantified formula, when non-empty.\n"
91
         "+ num\n"
92
         "  Print the total number of instantiations per quantified formula, when\n"
93
         "  non-zero.\n";
94
    std::exit(1);
95
  }
96
  throw OptionException(std::string("unknown option for --print-inst: `") +
97
                        optarg + "'.  Try --print-inst=help.");
98
}
99
100
namespace printer
101
{
102
// clang-format off
103
void setDefaultFlattenHOChains(Options& opts, bool value)
104
{
105
    if (!opts.printer.flattenHOChainsWasSetByUser) {
106
        opts.printer.flattenHOChains = value;
107
    }
108
}
109
void setDefaultInstFormatMode(Options& opts, InstFormatMode value)
110
{
111
    if (!opts.printer.instFormatModeWasSetByUser) {
112
        opts.printer.instFormatMode = value;
113
    }
114
}
115
void setDefaultModelFormatMode(Options& opts, ModelFormatMode value)
116
{
117
    if (!opts.printer.modelFormatModeWasSetByUser) {
118
        opts.printer.modelFormatMode = value;
119
    }
120
}
121
void setDefaultPrintInstFull(Options& opts, bool value)
122
{
123
    if (!opts.printer.printInstFullWasSetByUser) {
124
        opts.printer.printInstFull = value;
125
    }
126
}
127
void setDefaultPrintInstMode(Options& opts, PrintInstMode value)
128
{
129
    if (!opts.printer.printInstModeWasSetByUser) {
130
        opts.printer.printInstMode = value;
131
    }
132
}
133
// clang-format on
134
}
135
136
29340
}  // namespace cvc5::options
137
// clang-format on