Changeset 4129


Ignore:
Timestamp:
Sep 4, 2014, 2:43:20 PM (5 years ago)
Author:
cameron
Message:

Revert CR introduction; eliminate unused code for 'predefined' syms

Location:
icGREP/icgrep-devel/icgrep
Files:
6 edited

Legend:

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

    r3984 r4129  
    1414std::list<PabloS*> CC_Compiler::compile(std::string basis_pattern,
    1515                                        std::string gensym_pattern,
    16                                         const std::map<std::string, RE*>& re_map,
    17                                         std::list<CC*> predefined)
     16                                        const std::map<std::string, RE*>& re_map)
    1817{
    1918    mEncoding.setBasisPattern(basis_pattern);
     
    3130
    3231    process_re_map(cgo, re_map);
    33     process_predefined(cgo, predefined);
    3432
    3533    return cgo.get_stmtsl();
     
    7068            process_re(cgo, *it);
    7169        }
    72     }
    73 }
    74 
    75 void CC_Compiler::process_predefined(CC_CodeGenObject &cgo, std::list<CC*> predefined)
    76 {
    77     std::list<CC*>::iterator it;
    78     for (it = predefined.begin(); it != predefined.end(); ++it)
    79     {
    80         cgo = cc2pablos(cgo, *it);
    8170    }
    8271}
  • icGREP/icgrep-devel/icgrep/cc_compiler.h

    r3984 r4129  
    3232    std::list<PabloS*> compile(std::string basis_pattern,
    3333                               std::string gensym_pattern,
    34                                const std::map<std::string, RE*>& re_map,
    35                                std::list<CC*> predefined);
     34                               const std::map<std::string, RE*>& re_map);
    3635private:
    3736    void process_re_map(CC_CodeGenObject& cgo, const std::map<std::string, RE*>& re_map);
    3837    void process_re(CC_CodeGenObject& cgo, RE* re);
    39     void process_predefined(CC_CodeGenObject& cgo, std::list<CC*> predefined);
    4038    std::string bit_var(int n);
    4139    PabloE* make_bitv(int n);
  • icGREP/icgrep-devel/icgrep/llvm_gen.cpp

    r4124 r4129  
    424424    Generate_PabloStatements(cg_state.stmtsl);
    425425    SetReturnMarker(cg_state.newsym, 0);
    426     SetReturnMarker(m_name_map.find("LF")->second, 1);
     426    SetReturnMarker(m_name_map.find("LineFeed")->second, 1);
    427427
    428428    //Terminate the block
  • icGREP/icgrep-devel/icgrep/pbix_compiler.cpp

    r4123 r4129  
    1212    m_name_map = name_map;
    1313    symgen = SymbolGenerator();
    14 }
    15 
    16 std::string Pbix_Compiler::lookupCC(std::string ccname) {
    17     return m_name_map.find(ccname)->second;
    1814}
    1915
     
    6460    std::string gs_m0 = symgen.gensym("start_marker");
    6561    cg_state.stmtsl.push_back(new Assign(gs_m0, new All(1)));
    66    
    67     std::string gs_linebreak = symgen.gensym("LineBreak");
    68     m_name_map.insert(make_pair("LineBreak", gs_linebreak));
    69         cg_state.stmtsl.push_back(new Assign(gs_linebreak, new Or(new Var(lookupCC("LF")), new Var(lookupCC("CR")))));
    70    
    7162
    7263    if (unicode_re(re))
    7364    {
    7465        cg_state.newsym = gs_m0;
    75         //Set the 'utf8.initial' bit stream for the utf-8 multi-byte encoding.
    76         std::string gs_initial = symgen.gensym("utf8.initial");
    77         m_name_map.insert(make_pair("utf8.initial", gs_initial));
    78         PabloE * u8single = new Var(lookupCC("UTF8-SingleByte"));
    79         PabloE * u8pfx2 = new Var(lookupCC("UTF8-Prefix2"));
    80         PabloE * u8pfx3 = new Var(lookupCC("UTF8-Prefix3"));
    81         PabloE * u8pfx4 = new Var(lookupCC("UTF8-Prefix4"));
     66        //Set the 'internal.initial' bit stream for the utf-8 multi-byte encoding.
     67        std::string gs_initial = symgen.gensym("internal.initial");
     68        m_name_map.insert(make_pair("internal.initial", gs_initial));
     69        PabloE * u8single = new Var(m_name_map.find("UTF8-SingleByte")->second);
     70        PabloE * u8pfx2 = new Var(m_name_map.find("UTF8-Prefix2")->second);
     71        PabloE * u8pfx3 = new Var(m_name_map.find("UTF8-Prefix3")->second);
     72        PabloE * u8pfx4 = new Var(m_name_map.find("UTF8-Prefix4")->second);
    8273        PabloE * u8pfx = new Or(new Or(u8pfx2, u8pfx3), u8pfx4);
    83             cg_state.stmtsl.push_back(new Assign(gs_initial, new Or(u8pfx, u8single)));
     74        cg_state.stmtsl.push_back(new Assign(gs_initial, new Or(u8pfx, u8single)));
    8475        cg_state.newsym = gs_initial;
    8576
    86         //Set the 'utf8.nonfinal' bit stream for the utf-8 multi-byte encoding.
     77        //Set the 'internal.nonfinal' bit stream for the utf-8 multi-byte encoding.
    8778        cg_state.newsym = gs_m0;
    88         std::string gs_nonfinal = symgen.gensym("utf8.nonfinal");
    89         m_name_map.insert(make_pair("utf8.nonfinal", gs_nonfinal));
     79        std::string gs_nonfinal = symgen.gensym("internal.nonfinal");
     80        m_name_map.insert(make_pair("internal.nonfinal", gs_nonfinal));
    9081//#define USE_IF_FOR_NONFINAL
    9182#ifdef USE_IF_FOR_NONFINAL
     
    113104    std::string gs_retVal = symgen.gensym("marker");
    114105    cg_state.stmtsl.push_back(new Assign(gs_retVal, new And(new MatchStar(new Var(cg_state.newsym),
    115         new Not(new Var(lookupCC("LineBreak")))), new Var(lookupCC("LineBreak")))));
     106        new Not(new Var(m_name_map.find("LineFeed")->second))), new Var(m_name_map.find("LineFeed")->second))));
    116107    cg_state.newsym = gs_retVal;
    117108
     
    127118        if (name->getType() != Name::FixedLength) {
    128119            // Move the markers forward through any nonfinal UTF-8 bytes to the final position of each character.
    129             markerExpr = new And(markerExpr, new CharClass(lookupCC("utf8.initial")));
    130             markerExpr = new ScanThru(markerExpr, new CharClass(lookupCC("utf8.nonfinal")));
     120            markerExpr = new And(markerExpr, new CharClass(m_name_map.find("internal.initial")->second));
     121            markerExpr = new ScanThru(markerExpr, new CharClass(m_name_map.find("internal.nonfinal")->second));
    131122        }       
    132123        PabloE* ccExpr;
     
    140131        }
    141132        if (name->isNegated()) {
    142             ccExpr = new Not(new Or(new Or(ccExpr, new CharClass(lookupCC("LineBreak"))),
    143                                     new CharClass(lookupCC("utf8.nonfinal"))));
     133            ccExpr = new Not(new Or(new Or(ccExpr, new CharClass(m_name_map.find("LineFeed")->second)),
     134                                    new CharClass(m_name_map.find("internal.nonfinal")->second)));
    144135        }
    145136        cg_state.stmtsl.push_back(new Assign(gs_retVal, new Advance(new And(ccExpr, markerExpr))));
     
    151142    {
    152143        std::string gs_retVal = symgen.gensym("start_of_line_marker");
    153         PabloE * CR_start = new And(new Advance(new Var(lookupCC("CR"))), new Not(new Var(lookupCC("LF"))));
    154         PabloE * LF_start = new Not(new Advance(new Not(new Var(lookupCC("LF")))));
    155         cg_state.stmtsl.push_back(new Assign(gs_retVal, new And(new Var(cg_state.newsym), new Or(CR_start, LF_start))));
     144        cg_state.stmtsl.push_back(new Assign(gs_retVal, new And(new Var(cg_state.newsym), new Not(new Advance(new Not(new CharClass(m_name_map.find("LineFeed")->second)))))));
    156145        cg_state.newsym = gs_retVal;
    157146    }
     
    159148    {
    160149        std::string gs_retVal = symgen.gensym("end_of_line_marker");
    161         cg_state.stmtsl.push_back(new Assign(gs_retVal, new And(new Var(cg_state.newsym), new CharClass(lookupCC("LineBreak")))));
     150        cg_state.stmtsl.push_back(new Assign(gs_retVal, new And(new Var(cg_state.newsym), new CharClass(m_name_map.find("LineFeed")->second))));
    162151        cg_state.newsym = gs_retVal;
    163152    }
     
    212201
    213202            if (rep_name->isNegated()) {
    214                 ccExpr = new Not(new Or(new Or(ccExpr, new CharClass(lookupCC("LineBreak"))),
    215                                         new CharClass(lookupCC("utf8.nonfinal"))));
     203                ccExpr = new Not(new Or(new Or(ccExpr, new CharClass(m_name_map.find("LineFeed")->second)),
     204                                        new CharClass(m_name_map.find("internal.nonfinal")->second)));
    216205            }
    217206            if (rep_name->getType() == Name::FixedLength)
     
    222211            {
    223212                cg_state.stmtsl.push_back(new Assign(gs_retVal,
    224                     new And(new MatchStar(new Var(cg_state.newsym), new Or(new CharClass(lookupCC("utf8.nonfinal")),
    225                     ccExpr)), new CharClass(lookupCC("utf8.initial")))));
     213                    new And(new MatchStar(new Var(cg_state.newsym), new Or(new CharClass(m_name_map.find("internal.nonfinal")->second),
     214                    ccExpr)), new CharClass(m_name_map.find("internal.initial")->second))));
    226215            }
    227216
  • icGREP/icgrep-devel/icgrep/pbix_compiler.h

    r4123 r4129  
    5858public:
    5959    Pbix_Compiler(std::map<std::string, std::string> name_map);
    60     std::string lookupCC(std::string ccname);
    6160    CodeGenState compile(RE *re);
    6261    CodeGenState compile_subexpressions(const std::map<std::string, RE*>& re_map);
  • icGREP/icgrep-devel/icgrep/re_compiler.cpp

    r4123 r4129  
    7171    std::string cc_name;
    7272    std::map<std::string,std::string> name_map;
    73     std::list<CC*> predefined_characters;
    7473
    7574    CC* cc_lf = new CC(0x0A);
    7675    cc_name = cc_lf->getName();
    7776    re_map.insert(make_pair(cc_name, cc_lf));
    78     name_map.insert(make_pair("LF", cc_name));
    79    
    80     CC* cc_cr = new CC(0x0D);
    81     cc_name = cc_cr->getName();
    82     re_map.insert(make_pair(cc_name, cc_cr));
    83     name_map.insert(make_pair("CR", cc_name));
    84    
     77    name_map.insert(make_pair("LineFeed", cc_name));
     78
    8579    CC* cc_utf8_single_byte = new CC(0x00, 0x7F);
    8680    cc_name = cc_utf8_single_byte->getName();
     
    10296    re_map.insert(make_pair(cc_name, cc_utf8_prefix4));
    10397    name_map.insert(make_pair("UTF8-Prefix4", cc_name));
    104    
    105    
    10698
    10799    CC_Compiler cc_compiler(encoding);
    108     std::list<PabloS*> cc_stmtsl = cc_compiler.compile(basis_pattern, gensym_pattern, re_map, predefined_characters);
     100    std::list<PabloS*> cc_stmtsl = cc_compiler.compile(basis_pattern, gensym_pattern, re_map);
    109101
    110102    //Print to the terminal the AST that was generated by the character class compiler.
Note: See TracChangeset for help on using the changeset viewer.