diff options
author | Tianyi Liang <tianyi-liang@uiowa.edu> | 2014-02-26 11:43:59 -0600 |
---|---|---|
committer | Tianyi Liang <tianyi-liang@uiowa.edu> | 2014-02-26 11:43:59 -0600 |
commit | 00bf0b5385f14702cc00bab25ae0e2bdc2fa0f49 (patch) | |
tree | f32afe6a25ecd73959166a5382901db64002618e | |
parent | 9a2552b90aa4dad355c648bfaaa29c1ade8a1912 (diff) |
add a new file
-rw-r--r-- | src/util/regexp.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/util/regexp.cpp b/src/util/regexp.cpp new file mode 100644 index 000000000..246f16243 --- /dev/null +++ b/src/util/regexp.cpp @@ -0,0 +1,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 */
\ No newline at end of file |