GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/util/sexpr.cpp Lines: 11 17 64.7 %
Date: 2021-05-24 Branches: 9 22 40.9 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Tim King, Morgan Deters, 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
 * Simple stateless conversion to s-expressions.
14
 */
15
16
#include "util/sexpr.h"
17
18
#include <iostream>
19
20
#include "util/integer.h"
21
#include "util/rational.h"
22
#include "util/statistics_value.h"
23
24
namespace cvc5 {
25
26
65
void toSExpr(std::ostream& out, const std::string& s)
27
{
28
65
  if (s == "true" || s == "false")
29
  {
30
    out << s;
31
    return;
32
  }
33
  try
34
  {
35
65
    Integer tmp(s);
36
    out << s;
37
    return;
38
  }
39
65
  catch (std::invalid_argument&)
40
  {
41
  }
42
  try
43
  {
44
65
    Rational tmp(s);
45
    out << s;
46
    return;
47
  }
48
65
  catch (std::invalid_argument&)
49
  {
50
  }
51
65
  out << "\"" << s << "\"";
52
}
53
60
void toSExpr(std::ostream& out, const std::unique_ptr<StatisticBaseValue>& sbv)
54
{
55
60
  out << *sbv;
56
60
}
57
58
28191
}  // namespace cvc5