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_ls_template.cpp

    r1228 r1232  
    5656char * source;
    5757LineColTracker tracker;
     58
     59static inline void ReportError(const char * error_msg, int error_pos_in_block) {
     60  int error_line, error_column;
     61  tracker.get_Line_and_Column(error_pos_in_block, error_line, error_column);
     62  fprintf(stderr, "%s at line %i, column %i\n", error_msg, error_line, error_column);
     63}
     64
     65class ErrorTracker {
     66public:
     67    ErrorTracker() { noted_pos_in_block = -1;}
     68
     69    inline void NoteError(const char * error_msg, BitBlock err_strm) {
     70      int pos_in_block = count_forward_zeroes(err_strm);
     71      if ((noted_pos_in_block == -1) || (noted_pos_in_block > pos_in_block)) {
     72        noted_pos_in_block = pos_in_block;
     73        noted_error = error_msg;
     74      }
     75    }
     76
     77    inline void If_Error_Report_First() {
     78      if (noted_pos_in_block > -1) {
     79              int error_line, error_column;
     80              ReportError(noted_error, noted_pos_in_block);
     81              exit(-1);
     82      }
     83    }
     84
     85private:
     86  const char * noted_error;
     87  int noted_pos_in_block;
     88};
     89
     90
    5891TagMatcher matcher;
    5992BitBlock EOF_mask = simd_const_1(1);
     93
     94ErrorTracker error_tracker;
    6095
    6196queue <size_t> elem_starts_buf;
     
    76111        }
    77112        return 0;
    78 }
    79 
    80 
    81 static inline void ReportError(const char * error_msg, int error_pos_in_block) {
    82   int error_line, error_column;
    83   tracker.get_Line_and_Column(error_pos_in_block, error_line, error_column);
    84   fprintf(stderr, "%s at line %i, column %i\n", error_msg, error_line, error_column);
    85113}
    86114
     
    319347                }
    320348
    321                 if (bitblock_has_bit(check_streams.error_mask)) {
    322                   int errpos = count_forward_zeroes(check_streams.error_mask);
    323                   ReportError("error found", errpos);
    324               exit(-1);
    325                 }
     349                error_tracker.If_Error_Report_First();
    326350
    327351                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.