Changeset 4334


Ignore:
Timestamp:
Dec 11, 2014, 12:18:14 PM (4 years ago)
Author:
cameron
Message:

Confine predefined stream creation to RE_compiler::initializeRequiredStreams

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

Legend:

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

    r4329 r4334  
    4646}
    4747
     48pablo::Var * CC_Compiler::compileCC(const re::CC *cc) {
     49     return mCG.createVar(mCG.createAssign(cc->canonicalName(), charset_expr(cc)));
     50}
     51
    4852std::vector<Var *> CC_Compiler::compile(const CC_NameMap & nameMap) {
    4953    for (Name * name : nameMap) {
     
    5357        computeVariableConstraints();
    5458    }
    55     return std::move(mBasisBit);
     59    return mBasisBit;
    5660}
    5761
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.h

    r4287 r4334  
    1414#include <unordered_map>
    1515#include <string>
     16#include <iostream>
    1617
    1718namespace cc {
     
    2728    std::vector<pablo::Var *> compile(const CC_NameMap & nameMap);
    2829
     30    pablo::Var * compileCC(const re::CC *cc);
    2931private:
    3032
  • icGREP/icgrep-devel/icgrep/cc/cc_namemap.cpp

    r4331 r4334  
    1313
    1414namespace cc {
    15 
    16 void CC_NameMap::addPredefined(const std::string friendlyName, re::CC * cc) {
    17     assert (cc);
    18     std::string classname = cc->canonicalName();
    19     Name * name = makeName(classname, cc);
    20     assert (name->getCC() == cc);
    21     mNameMap.insert(std::make_pair(friendlyName, name));   
    22     insert(std::move(classname), name);
    23     assert (name->getCC() == cc);
    24 }
    2515
    2616RE * CC_NameMap::process(RE * re) {
  • icGREP/icgrep-devel/icgrep/cc/cc_namemap.hpp

    r4331 r4334  
    2424
    2525    re::RE * process(re::RE * re);
    26 
    27     void addPredefined(const std::string friendlyName, re::CC * cc);
    2826
    2927    inline const re::Name * operator[](const std::string & name) const {
  • icGREP/icgrep-devel/icgrep/compiler.cpp

    r4331 r4334  
    9393
    9494    // note: system is clumbersome at the moment; this ought to be done AFTER toUTF8.
    95     nameMap.addPredefined("LineFeed", makeCC(0x0A));
     95    //nameMap.addPredefined("LineFeed", makeCC(0x0A));
    9696    #ifdef DEBUG_PRINT_RE_AST
    9797    std::cerr << "NameMap:\n" << nameMap.printMap() << std::endl;
     
    117117
    118118    RE_Compiler re_compiler(main, nameMap);
    119     re_compiler.initializeRequiredStreams();
     119    re_compiler.initializeRequiredStreams(cc_compiler);
    120120    re_compiler.finalizeMatchResult(re_compiler.compile(re_ast));
    121121    #ifdef DEBUG_PRINT_PBIX_AST
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4330 r4334  
    4343
    4444   
    45 void RE_Compiler::initializeRequiredStreams() {
    46 
    47     mLineFeed = mNameMap["LineFeed"]->getCompiled();
    48 
     45void RE_Compiler::initializeRequiredStreams(cc::CC_Compiler & ccc) {
     46
     47    mLineFeed = ccc.compileCC(makeCC(0x0A));
     48    PabloAST * u8single = ccc.compileCC(makeCC(0x00, 0x7F));
     49    PabloAST * u8pfx2 = ccc.compileCC(makeCC(0xC2, 0xDF));
     50    PabloAST * u8pfx3 = ccc.compileCC(makeCC(0xE0, 0xEF));
     51    PabloAST * u8pfx4 = ccc.compileCC(makeCC(0xF0, 0xF4));
     52   
    4953    const std::string initial = "initial";
    5054    const std::string nonfinal = "nonfinal";
    5155
    52     //Set the 'internal.initial' bit stream for the utf-8 multi-byte encoding.
    53     PabloAST * u8single = mNameMap["UTF8-SingleByte"]->getCompiled();
    54     PabloAST * u8pfx2 = mNameMap["UTF8-Prefix2"]->getCompiled();
    55     PabloAST * u8pfx3 = mNameMap["UTF8-Prefix3"]->getCompiled();
    56     PabloAST * u8pfx4 = mNameMap["UTF8-Prefix4"]->getCompiled();
    5756    PabloAST * u8pfx = mCG.createOr(mCG.createOr(u8pfx2, u8pfx3), u8pfx4);
    5857    mInitial = mCG.createVar(mCG.createAssign(initial, mCG.createOr(u8pfx, u8single)));
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r4330 r4334  
    99
    1010#include <re/re_re.h>
     11#include <cc/cc_compiler.h>
    1112
    1213#include <string>
     
    3031
    3132    RE_Compiler(pablo::PabloBlock & baseCG, const cc::CC_NameMap & nameMap);
    32     void initializeRequiredStreams();
     33    void initializeRequiredStreams(cc::CC_Compiler & ccc);
    3334    void finalizeMatchResult(pablo::Assign * match_result);
    3435    pablo::Assign * compile(RE * re) {
  • icGREP/icgrep-devel/icgrep/utf8_encoder.cpp

    r4249 r4334  
    3535    }
    3636    ast = nameMap.process(ast);
    37     // Build our list of predefined characters.
    38     nameMap.addPredefined("UTF8-SingleByte", makeCC(0x00, 0x7F));
    39     nameMap.addPredefined("UTF8-Prefix2", makeCC(0xC2, 0xDF));
    40     nameMap.addPredefined("UTF8-Prefix3", makeCC(0xE0, 0xEF));
    41     nameMap.addPredefined("UTF8-Prefix4", makeCC(0xF0, 0xF4));
    4237    return ast;
    4338}
Note: See TracChangeset for help on using the changeset viewer.