Changeset 3015


Ignore:
Timestamp:
Apr 12, 2013, 4:34:21 PM (6 years ago)
Author:
bhull
Message:

RE Changes

Location:
proto/RE
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • proto/RE/output/pablo_template.cpp

    r3005 r3015  
    134134
    135135    @decl
    136 
     136        ForwardScanner<BitBlock, ScanWord> match_scanner;
     137        ForwardScanner<BitBlock, ScanWord> line_scanner;
     138bool line_match_found=false;
     139
     140
     141        int match_count=0;
    137142    int block_base  = 0;
    138143                int block_pos   = 0;
     
    182187
    183188          @block_stmts
    184 print_register2("Matches",output.matches, 128);
     189
     190
     191match_scanner.init(&output.matches);
     192line_scanner.init(&lex.LF);
     193match_scanner.scan_to_next();
     194line_scanner.scan_to_next();
     195while(!(match_scanner.is_done() || line_scanner.is_done())) {
     196        if (line_scanner.get_pos()<match_scanner.get_pos()) {
     197                line_match_found=false;
     198                line_scanner.scan_to_next();
     199        } else {
     200                if (!line_match_found) {
     201                        match_count++;
     202                        line_match_found=true;
     203                }
     204                match_scanner.scan_to_next();
     205        }
     206
     207}
     208if (!line_scanner.is_done()) {
     209        line_match_found=false;
     210} else if (!match_scanner.is_done()) {
     211        if (!line_match_found) {
     212                match_count++;
     213                line_match_found=true;
     214        }
     215
     216}
     217while(!match_scanner.is_done()) {
     218        match_count++;
     219        match_scanner.scan_to_next();
     220}
     221//print_register2("Matches",output.matches, 128);
    185222      }
    186223      PERF_SEC_END(parser_timer, chars_avail);
     
    208245                                s2p_do_block((BytePack *) &src_buffer[block_pos], basis_bits);
    209246                                @block_stmts
    210                                 print_register2("Matches",output.matches,128);
     247match_scanner.init(&output.matches);
     248line_scanner.init(&lex.LF);
     249match_scanner.scan_to_next();
     250line_scanner.scan_to_next();
     251while(!(match_scanner.is_done() || line_scanner.is_done())) {
     252        if (line_scanner.get_pos()<match_scanner.get_pos()) {
     253                line_match_found=false;
     254                line_scanner.scan_to_next();
     255        } else {
     256                if (!line_match_found) {
     257                        match_count++;
     258                        line_match_found=true;
     259                }
     260                match_scanner.scan_to_next();
     261        }
     262
     263}
     264if (!line_scanner.is_done()) {
     265        line_match_found=false;
     266} else if (!match_scanner.is_done()) {
     267        if (!line_match_found) {
     268                match_count++;
     269                line_match_found=true;
     270        }
     271
     272}
     273
     274
     275
     276                                //print_register2("Matches",output.matches,128);
    211277       block_pos += BLOCK_SIZE;
    212278          remaining -= BLOCK_SIZE;
     
    224290                                s2p_do_final_block((BytePack *) &src_buffer[block_pos], basis_bits, EOF_mask);
    225291          @final_block_stmts
    226 print_register2("Matches",output.matches,128);
     292
     293match_scanner.init(&output.matches);
     294line_scanner.init(&lex.LF);
     295match_scanner.scan_to_next();
     296line_scanner.scan_to_next();
     297while(!(match_scanner.is_done() || line_scanner.is_done())) {
     298        if (line_scanner.get_pos()<match_scanner.get_pos()) {
     299                line_match_found=false;
     300                line_scanner.scan_to_next();
     301        } else {
     302                if (!line_match_found) {
     303                        match_count++;
     304                        line_match_found=true;
     305                }
     306                match_scanner.scan_to_next();
     307        }
     308
     309}
     310if (!line_scanner.is_done()) {
     311        line_match_found=false;
     312} else if (!match_scanner.is_done()) {
     313        if (!line_match_found) {
     314                match_count++;
     315                line_match_found=true;
     316        }
     317
     318}
     319
     320//print_register2("Matches",output.matches,128);
    227321#ifdef USE_ANY_CARRY_TEST
    228322   }
     
    233327
    234328                PERF_SEC_END(parser_timer, chars_avail);
    235 }
    236 
     329printf("Matching Lines:%d\n",match_count);
     330}
     331
  • proto/RE/src/codeGenerator/CodeGenerator.java

    r2360 r3015  
    4747                        //is this the fastest way to do this?                   
    4848                        if (repetitionType.equals("*")) {
    49                                 Output add = oG.makeAdd(oG.makeVariable(nodeState.getCursorVariable()), oG.makeVariable(characterClassVariables.get(childState.getCharacterClassRepresentationString())));
    50                                 Output andNot = oG.makeAnd(add, oG.makeNot(oG.makeVariable(characterClassVariables.get(childState.getCharacterClassRepresentationString()))));
    51                                 Output or = oG.makeOr(andNot, oG.makeVariable(nodeState.getCursorVariable()));
    52                                 out = oG.makeAssignment(oG.makeVariable(nodeState.getCursorVariable()), or);
     49                                //Output add = oG.makeAdd(oG.makeAnd(oG.makeVariable(nodeState.getCursorVariable()),oG.makeVariable(characterClassVariables.get(childState.getCharacterClassRepresentationString()))), oG.makeVariable(characterClassVariables.get(childState.getCharacterClassRepresentationString())));
     50                                //Output xOr = oG.makeXOr(add, oG.makeVariable(characterClassVariables.get(childState.getCharacterClassRepresentationString())));
     51                                //Output or = oG.makeOr(xOr, oG.makeVariable(nodeState.getCursorVariable()));
     52
     53
     54
     55                                Output matchStar = oG.makeMatchStar(oG.makeVariable(nodeState.getCursorVariable()), oG.makeVariable(characterClassVariables.get(childState.getCharacterClassRepresentationString())));
     56                                out = oG.makeAssignment(oG.makeVariable(nodeState.getCursorVariable()), matchStar);
    5357                        }
    5458                        if (repetitionType.equals("+")) {
    5559                                out = oG.combineStatements(cursorAssign, body);
    5660                                out = oG.combineStatements(out, oG.makeAssignment(oG.makeVariable(nodeState.getCursorVariable()), oG.makeVariable(childState.getCursorVariable())));
    57                                 Output add = oG.makeAdd(oG.makeVariable(nodeState.getCursorVariable()), oG.makeVariable(characterClassVariables.get(childState.getCharacterClassRepresentationString())));
    58                                 Output andNot = oG.makeAnd(add, oG.makeNot(oG.makeVariable(characterClassVariables.get(childState.getCharacterClassRepresentationString()))));
    59                                 Output or = oG.makeOr(andNot, oG.makeVariable(nodeState.getCursorVariable()));
    60                                 out = oG.combineStatements(out,oG.makeAssignment(oG.makeVariable(nodeState.getCursorVariable()), or));
     61                               
     62                                Output matchStar = oG.makeMatchStar(oG.makeVariable(nodeState.getCursorVariable()), oG.makeVariable(characterClassVariables.get(childState.getCharacterClassRepresentationString())));
     63                                                               
     64                                //Output add = oG.makeAdd(oG.makeAnd(oG.makeVariable(nodeState.getCursorVariable()),oG.makeVariable(characterClassVariables.get(childState.getCharacterClassRepresentationString()))), oG.makeVariable(characterClassVariables.get(childState.getCharacterClassRepresentationString())));
     65                                //Output xOr = oG.makeXOr(add, oG.makeVariable(characterClassVariables.get(childState.getCharacterClassRepresentationString())));
     66                                //Output or = oG.makeOr(xOr, oG.makeVariable(nodeState.getCursorVariable()));
     67                                out = oG.combineStatements(out,oG.makeAssignment(oG.makeVariable(nodeState.getCursorVariable()), matchStar));
    6168                        }
    6269                       
  • proto/RE/src/codeGenerator/OutputGenerator.java

    r2331 r3015  
    1212        public Output makeXOr(Output op1, Output op2);
    1313        public Output makeAdd(Output op1, Output op2);
    14        
     14        public Output makeMatchStar(Output op1, Output op2);
    1515       
    1616}
  • proto/RE/src/codeGenerator/PythonGenerator.java

    r3005 r3015  
    2222
    2323        @Override
     24        public Output makeMatchStar(Output op1, Output op2) {
     25
     26                return new PythonOutput("pablo.MatchStar("+op1 +", "+op2+")");
     27        }
     28
     29        @Override
    2430        public Output makeOr(Output op1, Output op2) {
    2531                return new PythonOutput("("+op1+" | "+op2+")");
     
    3339        @Override
    3440        public Output makeAdd(Output op1, Output op2) {
    35                 return new PythonOutput("("+op1+" + "+op2+")");
     41                //return new PythonOutput("("+op1+" + "+op2+")");
     42                return new PythonOutput("pablo.Add("+op1+", "+op2+")");
    3643        }
    3744       
Note: See TracChangeset for help on using the changeset viewer.