blob: 246f1624382b3d3246b967e3ecc6297c5fc80f55 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/********************* */
/*! \file regexp.cpp
** \verbatim
** Original author: Tianyi Liang
** Major contributors: none
** Minor contributors (to current version): Morgan Deters
** This file is part of the CVC4 project.
** Copyright (c) 2009-2013 New York University and The University of Iowa
** See the file COPYING in the top-level source directory for licensing
** information.\endverbatim
**
** \brief [[ Add one-line brief description here ]]
**
** [[ Add lengthier description here ]]
** \todo document this file
**/
#include "util/regexp.h"
#include <iostream>
using namespace std;
namespace CVC4 {
std::string String::toString() const {
std::string str;
for(unsigned int i=0; i<d_str.size(); ++i) {
char c = convertUnsignedIntToChar( d_str[i] );
if(isprint( c )) {
if(c == '\\') {
str += "\\\\";
} else if(c == '\"') {
str += "\\\"";
} else {
str += c;
}
} else {
std::string s;
switch(c) {
case '\a': s = "\\a"; break;
case '\b': s = "\\b"; break;
case '\t': s = "\\t"; break;
case '\r': s = "\\r"; break;
case '\v': s = "\\v"; break;
case '\f': s = "\\f"; break;
case '\n': s = "\\n"; break;
case '\e': s = "\\e"; break;
default : {
std::string s2 = static_cast<std::ostringstream*>( &(std::ostringstream() << (int)c) )->str();
if(s2.size() == 1) {
s2 = "0" + s2;
}
s = "\\x" + s2;
}
}
str += s;
}
}
return str;
}
std::ostream& operator <<(std::ostream& os, const String& s) {
return os << "\"" << s.toString() << "\"";
}
std::ostream& operator<<(std::ostream& out, const RegExp& s) {
return out << "regexp(" << s.getType() << ')';
}
}/* CVC4 namespace */
|