Ignore:
Timestamp:
Feb 8, 2013, 12:35:48 PM (6 years ago)
Author:
lindanl
Message:

Add numeric processing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/PDF/cb_template.cpp

    r2901 r2902  
    1414#include "../../simd-lib/s2p.hpp"
    1515#include "../../simd-lib/p2s.hpp"
     16#include <math.h>
    1617
    1718#include "../../simd-lib/perflib/perfsec.h"
    18 
     19using namespace std;
     20#include <iostream>
    1921
    2022
     
    3537BitBlock EOF_mask = simd<1>::constant<1>();
    3638
    37 static inline int Name_check(int pos);
    38 static inline int String_check(int pos);
    39 static inline int Hex_check(int pos);
    40 static inline int Digit_check(int pos);
    41 static inline int Keyword_check(int pos);
    42 static inline int Array_check(int pos);
     39
     40static inline int Digit_postprocessing(char * source, int pos);
    4341
    4442@global
     
    4947void do_process(FILE *infile, FILE *outfile, int filesize);
    5048
    51 
     49#define MAX_NUM 1000
     50int numbers[MAX_NUM];
     51int dec_pl[MAX_NUM];
     52int num_idx=0;
     53
     54
     55static inline int Digit_postprocessing(char * source, int pos) {
     56    bool negative= false;
     57    int num = 0;
     58    int start_pos;
     59    if (source[pos] == '-')     {
     60      pos++;
     61      negative = true;
     62    }
     63    else if (source[pos] == '+')
     64      pos++;
     65
     66    while ('0' <= source[pos] && source[pos] <= '9' || source[pos]=='.'){
     67      if(source[pos]=='.'){
     68        pos++;
     69        start_pos = pos;
     70        continue;
     71      }
     72      num = num * 10 + source[pos] - '0';
     73      pos++;
     74    }
     75    if (negative) (num) = -(num);
     76    numbers[num_idx] = num;
     77    dec_pl[num_idx] = pow(10, pos - start_pos);
     78    num_idx++;
     79}
    5280
    5381int main(int argc, char * argv[]) {
     
    214242}
    215243
     244static inline void Postprocessing(char* src, Marker marker){   
     245 
     246    if(bitblock::any(marker.numeric_starts)){
     247      BitBlockForwardIterator iter;
     248      iter.init(&(marker.numeric_starts));
     249      BitBlockForwardIterator iter_end;
     250      while(iter != iter_end) {
     251          Digit_postprocessing(src, *iter);
     252          iter++;
     253      }
     254    }
     255}
     256
    216257void do_process(FILE *infile, FILE *outfile, int filesize) {
    217258 
     
    258299      parse_HexStrings.do_block(lex[i], marker, out_Callouts);
    259300      parse_Names.do_block(lex[i], marker, out_Callouts, lex[i+1]);
     301      parse_Numeric.do_block(lex[i], marker, out_Callouts);
    260302      prepare_content_buffer.do_block(basis_bits[i], lex[i], marker, parity, escape_Callouts, out_Callouts, lex[i+1]);
    261303      Build_ContentBuffer(out_Callouts, content_buf, &content_buf_ptr);
    262     }
     304      Postprocessing(&srcbuf[i*BLOCK_SIZE], marker);
     305    }
     306   
    263307    /*final block*/
    264308    EOF_mask = bitblock::srl(simd<1>::constant<1>(), convert(BLOCK_SIZE-chars_avail));
     
    266310    parse_HexStrings.do_final_block(lex[BLOCKS-1], marker, out_Callouts, EOF_mask);
    267311    parse_Names.do_final_block(lex[BLOCKS-1], marker, out_Callouts, EOF_mask);
     312    parse_Numeric.do_block(lex[BLOCKS-1], marker, out_Callouts);
    268313    prepare_content_buffer.do_final_block(basis_bits[BLOCKS-1], lex[BLOCKS-1], marker, parity, escape_Callouts, out_Callouts, EOF_mask);
    269314    out_Callouts.delmask |= ~EOF_mask;         
    270315    Build_ContentBuffer(out_Callouts, content_buf, &content_buf_ptr);
    271 /*
    272 
    273     while (chars_avail >= BLOCK_SIZE) {
    274           s2p_do_block((BytePack *) &srcbuf[block_base], basis_bits);
    275           @block_stmts                   
    276           Build_ContentBuffer(out_Callouts, content_buf, &content_buf_ptr);
    277                   block_base += BLOCK_SIZE;
    278           chars_avail -= BLOCK_SIZE;
    279     }
    280 
    281     if (chars_avail > 0 || @any_carry) {
    282           EOF_mask = bitblock::srl(simd<1>::constant<1>(), convert(BLOCK_SIZE-chars_avail));
    283           s2p_do_final_block((BytePack *) &srcbuf[block_base], basis_bits, EOF_mask);
    284           @final_block_stmts
    285           out_Callouts.delmask |= ~EOF_mask;         
    286           Build_ContentBuffer(out_Callouts, content_buf, &content_buf_ptr);
    287     }
    288 */   
     316    Postprocessing(&srcbuf[(BLOCKS-1)*BLOCK_SIZE], marker);
     317
     318   
     319//     for(int i=0;i<num_idx;i++)
     320//       printf("%i,%i\n",numbers[i],dec_pl[i]);
     321 
    289322    PERF_SEC_END(parser_timer, chars_read);
    290323   
Note: See TracChangeset for help on using the changeset viewer.