Changeset 842 for proto


Ignore:
Timestamp:
Dec 18, 2010, 3:45:01 PM (9 years ago)
Author:
lindanl
Message:

Report error positions with line/column

Location:
proto/parabix2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/pablo_template.c

    r838 r842  
    4949int buffer_last;
    5050char * source;
     51LineColTracker tracker;
    5152
    5253
     
    6869
    6970
     71static inline void ReportError(const char * errmsg, int error_pos) {
     72  fprintf(stderr, "%s at line %i, column %i\n",
     73          errmsg,
     74          tracker.getLineNumber(error_pos),
     75          tracker.getColNumber(error_pos));
     76}
     77
     78
    7079static inline int NameStrt_check(int pos) {
    7180        int block_pos = block_base + pos;
    7281        if(XML_10_UTF8_NameStrt_bytes((unsigned char*)&source[block_pos]) == 0){
    73               fprintf(stderr, "name start error found at position %i\n",block_pos+buffer_base);
     82              ReportError("name start error", pos);
    7483              exit(-1);
    7584        }
     
    8089        int block_pos = block_base + pos;
    8190        if(XML_10_UTF8_NameChar_bytes((unsigned char*)&source[block_pos]) == 0){
    82               fprintf(stderr, "name error found at position %i\n",block_pos+buffer_base);
     91              ReportError("name error", pos);
    8392              exit(-1);
    8493        }
     
    92101              // "<?xml" legal at start of file.
    93102              if ((file_pos == 2) && at_XmlDecl_start<ASCII>((unsigned char*)&source[0])) return 0;
    94               fprintf(stderr, "[Xx][Mm][Ll] illegal as PI name at position %i\n",file_pos);
     103              ReportError("[Xx][Mm][Ll] illegal as PI name", pos);
    95104              exit(-1);
    96105        }
     
    101110        int block_pos = block_base + pos;
    102111        if (!at_CDATA1<ASCII>((unsigned char*)&source[block_pos])){
    103               fprintf(stderr, "CDATA error found at position %i\n",block_pos+buffer_base);
     112              ReportError("CDATA error", pos);
    104113              exit(-1);
    105114        }
     
    111120        unsigned char* s = (unsigned char*)&source[block_pos];
    112121        if (!(at_Ref_gt<ASCII>(s)||at_Ref_lt<ASCII>(s)||at_Ref_amp<ASCII>(s)||at_Ref_quot<ASCII>(s)||at_Ref_apos<ASCII>(s))){
    113               fprintf(stderr, "Undefined Reference found at position %i\n",block_pos+buffer_base);
     122              ReportError("Undefined reference", pos);
    114123              exit(-1);
    115124        }
     
    124133          ch_val = HexVal<ASCII>(s[0]) + (ch_val<<4);
    125134          if (ch_val> 0x10FFFF ){
    126             fprintf(stderr, "Illegal character reference found at position %i\n",block_pos+buffer_base);
     135            ReportError("Illegal character reference", pos);
    127136            exit(-1);
    128137          }
     
    130139        }
    131140        if ((ch_val == 0x0) || ((ch_val | 0x7FF) == 0xDFFF)|| ((ch_val | 0x1) == 0xFFFF)){
    132           fprintf(stderr, "Illegal character reference found at position %i\n",block_pos+buffer_base);
     141          ReportError("Illegal character reference", pos);
    133142          exit(-1);
    134143        }
    135144        else if (((ch_val < 0x20) && (ch_val != 0x9) && (ch_val != 0xD) && (ch_val != 0xA))){
    136           fprintf(stderr, "Illegal XML 1.0 character reference found at position %i\n",block_pos+buffer_base);
     145          ReportError("Illegal XML 1.0 character reference", pos);
    137146          exit(-1);
    138147        }
     
    147156          ch_val = DigitVal<ASCII>(s[0]) + ch_val*10;
    148157          if (ch_val> 0x10FFFF ){
    149             fprintf(stderr, "Illegal character reference found at position %i\n",block_pos+buffer_base);
     158            ReportError("Illegal character reference", pos);
    150159            exit(-1);
    151160          }
     
    153162        }
    154163        if ((ch_val == 0x0) || ((ch_val | 0x7FF) == 0xDFFF)|| ((ch_val | 0x1) == 0xFFFF)){
    155           fprintf(stderr, "Illegal character reference found at position %i\n",block_pos+buffer_base);
     164          ReportError("Illegal character reference", pos);
    156165          exit(-1);
    157166        }
    158167        else if (((ch_val < 0x20) && (ch_val != 0x9) && (ch_val != 0xD) && (ch_val != 0xA))){
    159           fprintf(stderr, "Illegal XML 1.0 character reference found at position %i\n",block_pos+buffer_base);
     168          ReportError("Illegal XML 1.0 character reference", pos);
    160169          exit(-1);
    161170        }
     
    183192          }
    184193          if (ch_val==60){
    185             fprintf(stderr, "Attribute values contain '<' characters after reference expansion at position %i\n",block_pos+buffer_base);
     194            ReportError("Attribute values contain '<' characters after reference expansion", pos);
    186195            exit(-1);
    187196          }       
    188197        }
    189198        else if(at_Ref_lt<ASCII>(s)){
    190           fprintf(stderr, "Attribute values contain '<' characters after reference expansion at position %i\n",block_pos+buffer_base);
     199          ReportError("Attribute values contain '<' characters after reference expansion", pos);
    191200          exit(-1);
    192201        }         
     
    200209
    201210
    202   LineColTracker tracker;
    203211
    204212  BytePack U8[8];
     
    326334
    327335        if (bitblock_has_bit(error_mask)) {
    328           fprintf(stderr, "error found at line %i, column %i\n",tracker.getLineNumber(error_mask), tracker.getColNumber(error_mask));
     336          int errpos = count_forward_zeroes(error_mask);
     337          ReportError("error found", errpos);
    329338          exit(-1);
    330339        }
     
    379388       
    380389        if (bitblock_has_bit(error_mask)) {
    381           fprintf(stderr, "error found at line %i, column %i\n",tracker.getLineNumber(error_mask), tracker.getColNumber(error_mask));
     390          int errpos = count_forward_zeroes(error_mask);
     391          ReportError("error found", errpos);
    382392          exit(-1);
    383393        }
  • proto/parabix2/src/LineColTracker.h

    r840 r842  
    2323  public:
    2424    LineColTracker();
    25     int getLineNumber(BitBlock marker);
    26     int getColNumber(BitBlock marker);
     25    int getLineNumber(int mark_pos);
     26    int getColNumber(int mark_pos);
    2727    inline void AdvanceBlock();
    2828    inline void StoreNewlines(BitBlock newline);
    29     void UpdateFromNewLineBuffer(BitBlock[] newline_strm; int blk_count);
    3029  private:
    3130    BitBlock BitParallelCounter[MAX_COUNTER_BITS];
     
    5958}
    6059
    61 int LineColTracker::getLineNumber(BitBlock marker){
     60int LineColTracker::getLineNumber(int mark_pos){
    6261  int lines = 1;
    63   int mark_pos = count_forward_zeroes(marker);
    6462  cur_newline = simd_andc(cur_newline, sisd_sfl(simd_const_1(1),sisd_from_int(mark_pos)));
    6563 
     
    7371}
    7472
    75 int LineColTracker::getColNumber(BitBlock marker){
    76   int mark_pos = count_forward_zeroes(marker);
     73int LineColTracker::getColNumber(int mark_pos){
    7774  cur_newline = simd_andc(cur_newline, sisd_sfl(simd_const_1(1),sisd_from_int(mark_pos)));
    7875  if(bitblock_has_bit(cur_newline))
    79     return mark_pos - (BLOCK_SIZE-count_backward_zeroes(cur_newline));
     76    return mark_pos - (BLOCK_SIZE-count_backward_zeroes(cur_newline))+1;
    8077  else
    8178    return BLOCK_SIZE*blocks_after_last_newline_block +
     
    8784}
    8885
    89 void LineColTracker::UpdateFromNewLineBuffer(BitBlock[] newline_strm; int blk_count) {
    90   int i, j, k;
    91   int last_blk = blk_count - 1;
    92   /* in case we find no newlines within the buffer, the
    93      number of blocks after the last newline grows by the
    94      full blk_count. */
    95   blocks_after_last_newline_block += blk_count;
    96   for (i = last_blk; i >= 0; i--) {
    97     if (bitblock_has_bit(newline_strm[i]) {
    98       last_block_with_newline = newline_strm[i];
    99       blocks_after_last_newline_block = last_blk - i;
    100       break;
    101     }
    102   last_blk = i; /* No newlines after this block. */
    103   j = 0;
    104   /* Process 7 blocks of the newline stream at a time. */
    105   while (j + 7 <= last_blk) {
    106     BitBlock s1, s2, c1, c2, t0, t1, t2;
    107     bitwise_full_add(newline_strm[j], newline_strm[j+1], newline_strm[j+2], s1, c1);
    108     bitwise_full_add(newline_strm[j+3], newline_strm[j+4], newline_strm[j+5], s2, c2);
    109     bitwise_half_add(s1, s2, newline_strm[j+6], t0, c3);  /* t0 is bit0 of 7 block sum */
    110     bitwise_full_add(c1, c2, c3, t1, t2); /*t1 and t2 are bits 1 and 2  of 7 block sum. */
    111     bitwise_half_add(t0, BitParallelCounter[0], BitParallelCounter[0], carry);
    112     bitwise_full_add(t1, BitParallelCounter[1], carry, BitParallelCounter[1], carry);
    113     bitwise_full_add(t2, BitParallelCounter[2], carry, BitParallelCounter[2], carry);
    114     bitwise_half_add(BitParallelCounter[3], carry, BitParallelCounter[3], carry);
    115     k = 3;
    116     while(bitblock_has_bit(carry)){
    117       k++;
    118       bitwise_half_add(carry,BitParallelCounter[k],BitParallelCounter[k],carry);
    119     }
    120   }
    121   while (j <= last_blk) {
    122     bitwise_half_add(newline_strm[j], BitParallelCounter[0], BitParallelCounter[0], carry);
    123     k = 0;
    124     while(bitblock_has_bit(carry)){
    125       k++;
    126       bitwise_half_add(carry,BitParallelCounter[k],BitParallelCounter[k],carry);
    127     }
    128   }
    129 }
    13086
    131 
  • proto/parabix2/src/perf_script.py

    r812 r842  
    44
    55
    6 testfile_home = "../../../../TD/"
     6testfile_home = "../../../../../TD/"
    77#programs = ['xmlwf','expat','Xerces_SAX','Xerces_DOM']
    8 programs = ['xmlwf']
     8programs = ['xmlwf','xmlwf_old']
    99testfiles = ['dew.xml','jaw.xml','arw.xml','po.xml','roads-2.gml','soap.xml']
    1010#testfiles = ['dew.u16','jaw.u16','po.u16','roads-2.u16','soap.u16']
Note: See TracChangeset for help on using the changeset viewer.