Ignore:
Timestamp:
Jul 28, 2011, 3:01:53 PM (8 years ago)
Author:
vla24
Message:

Updated symbol table implementation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/SymbolTable/symtab_pbgs_log_template.cpp

    r1231 r1232  
    5858char * source;
    5959LineColTracker tracker;
     60
     61static inline void ReportError(const char * error_msg, int error_pos_in_block) {
     62  int error_line, error_column;
     63  tracker.get_Line_and_Column(error_pos_in_block, error_line, error_column);
     64  fprintf(stderr, "%s at line %i, column %i\n", error_msg, error_line, error_column);
     65}
     66
     67class ErrorTracker {
     68public:
     69    ErrorTracker() { noted_pos_in_block = -1;}
     70
     71    inline void NoteError(const char * error_msg, BitBlock err_strm) {
     72      int pos_in_block = count_forward_zeroes(err_strm);
     73      if ((noted_pos_in_block == -1) || (noted_pos_in_block > pos_in_block)) {
     74        noted_pos_in_block = pos_in_block;
     75        noted_error = error_msg;
     76      }
     77    }
     78
     79    inline void If_Error_Report_First() {
     80      if (noted_pos_in_block > -1) {
     81              int error_line, error_column;
     82              ReportError(noted_error, noted_pos_in_block);
     83              exit(-1);
     84      }
     85    }
     86
     87private:
     88  const char * noted_error;
     89  int noted_pos_in_block;
     90};
     91
     92
    6093TagMatcher matcher;
    6194BitBlock EOF_mask = simd_const_1(1);
     95
     96ErrorTracker error_tracker;
     97
    6298BitBlock elem_starts;
    6399int previous_block_last_elem_start;
     
    291327    }
    292328    return 0;
    293 }
    294 
    295 static inline void ReportError(const char * error_msg, int error_pos_in_block) {
    296   int error_line, error_column;
    297   tracker.get_Line_and_Column(error_pos_in_block, error_line, error_column);
    298   fprintf(stderr, "%s at line %i, column %i\n", error_msg, error_line, error_column);
    299329}
    300330
     
    523553    }
    524554
    525     if (bitblock_has_bit(check_streams.error_mask)) {
    526       int errpos = count_forward_zeroes(check_streams.error_mask);
    527       ReportError("error found", errpos);
    528         exit(-1);
    529     }
     555    error_tracker.If_Error_Report_First();
    530556
    531557    matcher.store_streams(check_streams.tag_marks, check_streams.name_follows, check_streams.misc_mask, chars_avail);
Note: See TracChangeset for help on using the changeset viewer.