return false;
}
Node RegExpOpr::convert1(unsigned cnt, Node n) {
- Trace("regexp-debug") << "Converting " << n << " ... " << std::endl;
+ Trace("regexp-debug") << "Converting " << n << " at " << cnt << "... " << std::endl;
Node r1, r2;
convert2(cnt, n, r1, r2);
Trace("regexp-debug") << "... getting r1=" << r1 << ", and r2=" << r2 << std::endl;
Node ret = NodeManager::currentNM()->mkNode(kind::REGEXP_CONCAT,
NodeManager::currentNM()->mkNode(kind::REGEXP_STAR, r1), r2);
ret = Rewriter::rewrite( ret );
- Trace("regexp-debug") << "... done convert, with return " << ret << std::endl;
+ Trace("regexp-debug") << "... done convert at " << cnt << ", with return " << ret << std::endl;
return ret;
}
void RegExpOpr::convert2(unsigned cnt, Node n, Node &r1, Node &r2) {
}
Node RegExpOpr::intersectInternal2( Node r1, Node r2, std::map< PairNodes, Node > cache, bool &spflag, unsigned cnt ) {
Trace("regexp-intersect") << "Starting INTERSECT:\n "<< mkString(r1) << ",\n " << mkString(r2) << std::endl;
+ //if(Trace.isOn("regexp-debug")) {
+ // Trace("regexp-debug") << "... with cache:\n";
+ // for(std::map< PairNodes, Node >::const_iterator itr=cache.begin();
+ // itr!=cache.end();itr++) {
+ // Trace("regexp-debug") << "(" << itr->first.first << "," << itr->first.second << ")->" << itr->second << std::endl;
+ // }
+ //}
if(spflag) {
//TODO: var
return Node::null();
PairNodes p(r1, r2);
std::map< PairNodes, Node >::const_iterator itrcache = cache.find(p);
if(itrcache != cache.end()) {
- rNode = convert1(cnt, itrcache->second);
+ rNode = itrcache->second;
} else {
if(checkConstRegExp(r1) && checkConstRegExp(r2)) {
std::vector< unsigned > cset;
Node r1l = derivativeSingle(r1, c);
Node r2l = derivativeSingle(r2, c);
std::map< PairNodes, Node > cache2(cache);
- PairNodes p(r1l, r2l);
+ PairNodes p(r1, r2);
cache2[ p ] = NodeManager::currentNM()->mkNode(kind::REGEXP_RV, NodeManager::currentNM()->mkConst(CVC4::Rational(cnt)));
Node rt = intersectInternal2(r1l, r2l, cache2, spflag, cnt+1);
rt = convert1(cnt, rt);
retStr += "]";
break;
}
+ case kind::REGEXP_RV: {
+ retStr += "<";
+ retStr += r[0].getConst<Rational>().getNumerator().toString();
+ retStr += ">";
+ break;
+ }
default:
Trace("strings-error") << "Unsupported term: " << r << " in RegExp." << std::endl;
//Assert( false );
for(unsigned i=0; i<node.getNumChildren(); ++i) {
if(node[i].getKind() == kind::REGEXP_UNION) {
Node tmpNode = prerewriteOrRegExp( node[i] );
- for(unsigned int j=0; j<tmpNode.getNumChildren(); ++j) {
- node_vec.push_back( tmpNode[j] );
+ if(tmpNode.getKind() == kind::REGEXP_UNION) {
+ for(unsigned int j=0; j<tmpNode.getNumChildren(); ++j) {
+ node_vec.push_back( tmpNode[j] );
+ }
+ } else {
+ node_vec.push_back( tmpNode );
}
flag = true;
} else if(node[i].getKind() == kind::REGEXP_EMPTY) {