Ignore:
Timestamp:
Dec 19, 2014, 1:25:37 PM (5 years ago)
Author:
cameron
Message:

Embed predefined streams in if-structures

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4347 r4352  
    6767}
    6868
    69 //#define USE_IF_FOR_NONFINAL 1
    70 //#define USE_IF_FOR_CRLF
     69#define USE_IF_FOR_NONFINAL 1
     70#define USE_IF_FOR_CRLF
    7171#define UNICODE_LINE_BREAK true
    7272
     
    7474void RE_Compiler::initializeRequiredStreams(cc::CC_Compiler & ccc) {
    7575
     76    const std::string initial = "initial";
     77    const std::string nonfinal = "nonfinal";
     78   
    7679    Assign * LF = mCG.createAssign("LF", ccc.compileCC(makeCC(0x0A)));
    7780    mLineFeed = mCG.createVar(LF);
    7881    PabloAST * CR = ccc.compileCC(makeCC(0x0D));
    79     PabloAST * LF_VT_FF_CR = ccc.compileCC(makeCC(0x0A, 0x0D));
    80     PabloAST * NEL = mCG.createAnd(mCG.createAdvance(ccc.compileCC(makeCC(0xC2)), 1), ccc.compileCC(makeCC(0x85)));
    81     PabloAST * E2_80 = mCG.createAnd(mCG.createAdvance(ccc.compileCC(makeCC(0xE2)), 1), ccc.compileCC(makeCC(0x80)));
    82     PabloAST * LS_PS = mCG.createAnd(mCG.createAdvance(E2_80, 1), ccc.compileCC(makeCC(0xA8,0xA9)));
    83     PabloAST * LB_chars = mCG.createOr(LF_VT_FF_CR, mCG.createOr(NEL, LS_PS));
    8482#ifndef USE_IF_FOR_CRLF
    8583    mCRLF = mCG.createAnd(mCG.createAdvance(CR, 1), mLineFeed);
     
    9189    mCRLF = mCG.createVar(acrlf);
    9290#endif
    93     mUnicodeLineBreak = mCG.createAnd(LB_chars, mCG.createNot(mCRLF));  // count the CR, but not CRLF
     91   
     92    PabloAST * LF_VT_FF_CR = ccc.compileCC(makeCC(0x0A, 0x0D));
    9493    PabloAST * u8single = ccc.compileCC(makeCC(0x00, 0x7F));
    9594    PabloAST * u8pfx2 = ccc.compileCC(makeCC(0xC2, 0xDF));
    9695    PabloAST * u8pfx3 = ccc.compileCC(makeCC(0xE0, 0xEF));
    9796    PabloAST * u8pfx4 = ccc.compileCC(makeCC(0xF0, 0xF4));
    98    
    99     const std::string initial = "initial";
    100     const std::string nonfinal = "nonfinal";
    101 
    10297    PabloAST * u8pfx = mCG.createOr(mCG.createOr(u8pfx2, u8pfx3), u8pfx4);
    10398    mInitial = mCG.createVar(mCG.createAssign(initial, mCG.createOr(u8pfx, u8single)));
    104    
     99
    105100    #ifndef USE_IF_FOR_NONFINAL
    106101    PabloAST * u8scope32 = mCG.createAdvance(u8pfx3, 1);
    107102    PabloAST * u8scope42 = mCG.createAdvance(u8pfx4, 1);
    108103    PabloAST * u8scope43 = mCG.createAdvance(u8scope42, 1);
     104    PabloAST * NEL = mCG.createAnd(mCG.createAdvance(ccc.compileCC(makeCC(0xC2)), 1), ccc.compileCC(makeCC(0x85)));
     105    PabloAST * E2_80 = mCG.createAnd(mCG.createAdvance(ccc.compileCC(makeCC(0xE2)), 1), ccc.compileCC(makeCC(0x80)));
     106    PabloAST * LS_PS = mCG.createAnd(mCG.createAdvance(E2_80, 1), ccc.compileCC(makeCC(0xA8,0xA9)));
     107    PabloAST * LB_chars = mCG.createOr(LF_VT_FF_CR, mCG.createOr(NEL, LS_PS));
    109108    mNonFinal = mCG.createVar(mCG.createAssign(nonfinal, mCG.createOr(mCG.createOr(u8pfx, u8scope32), mCG.createOr(u8scope42, u8scope43))));
     109    mUnicodeLineBreak = mCG.createAnd(LB_chars, mCG.createNot(mCRLF));  // count the CR, but not CRLF
    110110    #endif
    111111    #ifdef USE_IF_FOR_NONFINAL
     
    115115    PabloAST * u8scope43 = it.createAdvance(u8scope42, 1);
    116116    Assign * a = it.createAssign(nonfinal, it.createOr(it.createOr(u8pfx, u8scope32), it.createOr(u8scope42, u8scope43)));
    117     mCG.createIf(u8pfx, std::move(std::vector<Assign *>{a}), std::move(it));
     117    PabloAST * NEL = it.createAnd(it.createAdvance(ccc.compileCC(makeCC(0xC2)), 1), ccc.compileCC(makeCC(0x85)));
     118    PabloAST * E2_80 = it.createAnd(it.createAdvance(ccc.compileCC(makeCC(0xE2)), 1), ccc.compileCC(makeCC(0x80)));
     119    PabloAST * LS_PS = it.createAnd(it.createAdvance(E2_80, 1), ccc.compileCC(makeCC(0xA8,0xA9)));
     120    Assign * NEL_LS_PS = it.createAssign("NEL_LS_PS", it.createOr(NEL, LS_PS));
     121    mCG.createIf(u8pfx, std::move(std::vector<Assign *>{a, NEL_LS_PS}), std::move(it));
     122    PabloAST * LB_chars = mCG.createOr(LF_VT_FF_CR, mCG.createVar(NEL_LS_PS));
    118123    mNonFinal = mCG.createVar(a);   
     124    mUnicodeLineBreak = mCG.createAnd(LB_chars, mCG.createNot(mCRLF));  // count the CR, but not CRLF
    119125    #endif
    120126}
Note: See TracChangeset for help on using the changeset viewer.