Ignore:
Timestamp:
Aug 4, 2014, 12:53:31 PM (5 years ago)
Author:
daled
Message:

Matchstar for utf-8 character classes works. Needs refactoring.

File:
1 edited

Legend:

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

    r3955 r3956  
    1919    for (auto it =  re_map.rbegin(); it != re_map.rend(); ++it)
    2020    {
     21        //This is specifically for the utf8 multibyte character classes.
    2122        if (Seq* seq = dynamic_cast<Seq*>(it->second))
    2223        {
     
    156157        else //Name::Unicode
    157158        {
    158             cg_state.stmtsl.push_back(new Assign(gs_retVal, new Advance(new And(new CharClass(name->getName()), new ScanThru(new Var(cg_state.newsym), new Var(m_name_map.find("internal.nonfinal")->second))))));
     159            cg_state.stmtsl.push_back(new Assign(gs_retVal, new Advance(new And(new CharClass(name->getName()), new ScanThru(new Var(cg_state.newsym), new CharClass(m_name_map.find("internal.nonfinal")->second))))));
    159160        }
    160161        cg_state.newsym = gs_retVal;
     
    210211        if ((dynamic_cast<Name*>(rep->getRE()) != 0) && (rep->getLB() == 0) && (rep->getUB()== unboundedRep))
    211212        {
    212             //std::cout << "Matchstar!" << std::endl;
     213            //std::cout << "Matchstar Name!" << std::endl;
    213214
    214215            Name* rep_name = dynamic_cast<Name*>(rep->getRE());
    215216            std::string gs_retVal = symgen.gensym("marker");
    216             cg_state.stmtsl.push_back(new Assign(gs_retVal, new MatchStar(new Var(cg_state.newsym), new CharClass(rep_name->getName()))));
     217
     218            if (rep_name->getType() == Name::FixedLength)
     219            {
     220                cg_state.stmtsl.push_back(new Assign(gs_retVal, new MatchStar(new Var(cg_state.newsym), new CharClass(rep_name->getName()))));
     221            }
     222            else if (rep_name->getType() == Name::UnicodeCategory)
     223            {
     224                // TODO:  ?? not too sure....
     225            }
     226            else //Name::unicode
     227            {
     228                std::string t_retVal = symgen.gensym("t");
     229                std::string u_retVal = symgen.gensym("u");
     230                std::string v_retVal = symgen.gensym("v");
     231                std::string new_cur_retVal = symgen.gensym("new_cur");
     232
     233                cg_state.stmtsl.push_back(new Assign(t_retVal, new Or(new CharClass(m_name_map.find("internal.nonfinal")->second), new CharClass(rep_name->getName()))));
     234                cg_state.stmtsl.push_back(new Assign(u_retVal, new MatchStar(new Var(cg_state.newsym), new Var(t_retVal))));
     235                cg_state.stmtsl.push_back(new Assign(v_retVal, new And(new Var(u_retVal), new CharClass(m_name_map.find("internal.initial")->second))));
     236                cg_state.stmtsl.push_back(new Assign(new_cur_retVal, new And(new Var(u_retVal), new Not(new Var(t_retVal)))));
     237
     238                cg_state.stmtsl.push_back(new Assign(gs_retVal, new Or(new Var(v_retVal), new Var(new_cur_retVal))));
     239
     240            }
     241
    217242            cg_state.newsym = gs_retVal;
    218243        }
Note: See TracChangeset for help on using the changeset viewer.