Ignore:
Timestamp:
Sep 1, 2014, 1:16:11 PM (5 years ago)
Author:
cameron
Message:

Bug fix for bounded repetition

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pbix_compiler.cpp

    r4117 r4121  
    246246        else if (rep->getUB() != unboundedRep)
    247247        {
    248             if ((rep->getLB() == 0) && (rep->getUB() == 0))
    249             {
    250                 //Just fall through...do nothing.
    251             }
    252             else if ((rep->getLB() == 0) && (rep->getUB() > 0))
    253             {
    254                 CodeGenState t1_cg_state = re2pablo_helper(rep->getRE(), cg_state);
    255                 rep->setUB(rep->getUB() - 1);
    256                 CodeGenState t2_cg_state = re2pablo_helper(re, t1_cg_state);
    257                 std::string gs_retVal = symgen.gensym("alt_marker");
    258                 cg_state.stmtsl = t2_cg_state.stmtsl;
    259                 cg_state.stmtsl.push_back(new Assign(gs_retVal, new Or(new Var(cg_state.newsym), new Var(t2_cg_state.newsym))));
    260                 cg_state.newsym = gs_retVal;
    261             }
    262             else //if ((rep->getLB() > 0) && (rep->getUB() > 0))
    263             {
    264                 CodeGenState t1_cg_state = re2pablo_helper(rep->getRE(), cg_state);
    265                 rep->setLB(rep->getLB() - 1);
    266                 rep->setUB(rep->getUB() - 1);
    267                 cg_state = re2pablo_helper(rep, t1_cg_state);
    268             }
    269         }
    270     }
    271 
    272     return cg_state;
    273 }
     248            cg_state = BoundedRep_helper(rep->getRE(), rep->getLB(), rep->getUB(), cg_state);
     249        }
     250    }
     251
     252    return cg_state;
     253}
     254
    274255
    275256CodeGenState Pbix_Compiler::Seq_helper(std::list<RE*>* lst, std::list<RE*>::const_iterator it, CodeGenState cg_state)
     
    305286}
    306287
     288CodeGenState Pbix_Compiler::BoundedRep_helper(RE* repeated, int lb, int ub, CodeGenState cg_state) {
     289    if ((lb == 0) && (ub == 0))
     290    {
     291    //Just fall through...do nothing.
     292    }
     293    else if ((lb == 0) && (ub > 0))
     294    {
     295         CodeGenState t1_cg_state = re2pablo_helper(repeated, cg_state);
     296         CodeGenState t2_cg_state = BoundedRep_helper(repeated, 0, ub-1, t1_cg_state);
     297         std::string gs_retVal = symgen.gensym("alt_marker");
     298         cg_state.stmtsl = t2_cg_state.stmtsl;
     299         cg_state.stmtsl.push_back(new Assign(gs_retVal, new Or(new Var(cg_state.newsym), new Var(t2_cg_state.newsym))));
     300         cg_state.newsym = gs_retVal;
     301    }
     302    else //if ((lb > 0) && (ub > 0))
     303    {
     304         CodeGenState t1_cg_state = re2pablo_helper(repeated, cg_state);
     305         cg_state = BoundedRep_helper(repeated, lb-1, ub-1, t1_cg_state);
     306    }
     307    return cg_state;
     308
     309}
     310
     311
    307312bool Pbix_Compiler::unicode_re(RE *re)
    308313{
Note: See TracChangeset for help on using the changeset viewer.