Changeset ddcedfe


Ignore:
Timestamp:
Dec 2, 2020, 1:01:01 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b37515b
Parents:
833ba13
Message:

Errors are now sorted by code-location/description

Location:
src/Common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Common/CodeLocation.h

    r833ba13 rddcedfe  
    4242        }
    4343
    44         bool followedBy( CodeLocation const & other, int seperation ) {
     44        bool startsBefore( CodeLocation const & other ) const {
     45                if( filename < other.filename ) return true;
     46                if( filename > other.filename ) return false;
     47
     48                if( first_line < other.first_line ) return true;
     49                if( first_line > other.first_line ) return false;
     50
     51                if( last_line < other.last_line ) return true;
     52                return false;
     53        }
     54
     55        bool followedBy( CodeLocation const & other, int seperation ) const {
    4556                return (first_line + seperation == other.first_line &&
    4657                        filename == other.filename);
    4758        }
    4859
    49         bool operator==( CodeLocation const & other ) {
     60        bool operator==( CodeLocation const & other ) const {
    5061                return followedBy( other, 0 );
    5162        }
    5263
    53         bool operator!=( CodeLocation const & other ) {
     64        bool operator!=( CodeLocation const & other ) const {
    5465                return !(*this == other);
    5566        }
  • src/Common/SemanticError.cc

    r833ba13 rddcedfe  
    9090void SemanticErrorException::print() {
    9191        using std::to_string;
     92
     93        errors.sort([](const error & lhs, const error & rhs) -> bool {
     94                if(lhs.location.startsBefore(rhs.location)) return true;
     95                if(rhs.location.startsBefore(lhs.location)) return false;
     96
     97                return lhs.description < rhs.description;
     98        });
     99
    92100        for( auto err : errors ) {
    93101                std::cerr << ErrorHelpers::bold() << err.location << ErrorHelpers::error_str() << ErrorHelpers::reset_font() << err.description << std::endl;
Note: See TracChangeset for help on using the changeset viewer.