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 |
63 |
void toSExpr(std::ostream& out, const std::string& s) |
27 |
|
{ |
28 |
63 |
if (s == "true" || s == "false") |
29 |
|
{ |
30 |
|
out << s; |
31 |
|
return; |
32 |
|
} |
33 |
|
try |
34 |
|
{ |
35 |
63 |
Integer tmp(s); |
36 |
|
out << s; |
37 |
|
return; |
38 |
|
} |
39 |
63 |
catch (std::invalid_argument&) |
40 |
|
{ |
41 |
|
} |
42 |
|
try |
43 |
|
{ |
44 |
63 |
Rational tmp(s); |
45 |
|
out << s; |
46 |
|
return; |
47 |
|
} |
48 |
63 |
catch (std::invalid_argument&) |
49 |
|
{ |
50 |
|
} |
51 |
63 |
out << "\"" << s << "\""; |
52 |
|
} |
53 |
58 |
void toSExpr(std::ostream& out, const std::unique_ptr<StatisticBaseValue>& sbv) |
54 |
|
{ |
55 |
58 |
out << *sbv; |
56 |
58 |
} |
57 |
|
|
58 |
22746 |
} // namespace cvc5 |