Example #1
0
string Replacements::replace(string sString) const {
    string sRetVal = sString;
    vector<Replacement*> replacements = getReplacements();

    for (int nAttempt = 0; nAttempt < 5; nAttempt++) {
        //cout << "loop: " << sRetVal << " >" << nAttempt << endl;
        bool fLoop = false;
        for (vector<Replacement*>::iterator it= replacements.begin();
             it != replacements.end(); it++) {

            string sNewString = (*it)->replace(sRetVal);
            if (sRetVal != sNewString) {
                sRetVal = sNewString;
                fLoop = true;
            }
        }

        if (!fLoop) break;
    }

	boost::trim(sRetVal);

    return sRetVal;
}
        if (REN_DYNAMIC_CAST(p, ApplicationNode*, node.get())) {

            ConcreteNodePtr function = copyAndReplace(p->getFunction(), rm);
            ConcreteNodeList arguments = p->getArguments();
            for (size_t i = 0; i < arguments.size(); ++i) {
                arguments[i] = copyAndReplace(arguments[i], rm);
            }

            return ConcreteNodePtr(new ApplicationNode(function, arguments));
                    
        } else if (REN_DYNAMIC_CAST(p, AbstractionNode*, node.get())) {

            return ConcreteNodePtr(
                new AbstractionNode(
                    p->getReplacements(),
                    copyAndReplace(p->getInside(), rm)));

        } else if (REN_DYNAMIC_CAST(p, ArgumentNode*, node.get())) {
            (void)p;
            return node;
        } else if (REN_DYNAMIC_CAST(p, FunctionNode*, node.get())) {
            (void)p;
            return node;
        } else if (REN_DYNAMIC_CAST(p, ValueNode*, node.get())) {
            (void)p;
            return node;
        } else {
            assert(!"ICE: Unknown Concrete Node Type");
            return node;
        }