Changes in src/Common/SemanticError.cc [3906301:138e29e]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/SemanticError.cc
r3906301 r138e29e 22 22 #include "SemanticError.h" 23 23 24 #include <unistd.h> 25 26 inline const std::string& error_str() { 27 static std::string str = isatty( fileno(stderr) ) ? "\e[31merror:\e[39m " : "error: "; 28 return str; 29 } 30 24 31 SemanticError::SemanticError() { 25 32 } 26 33 27 34 SemanticError::SemanticError( std::string error ) { 28 35 append( error ); 29 36 } 30 37 31 38 void SemanticError::append( SemanticError &other ) { 32 39 errors.splice( errors.end(), other.errors ); 33 40 } 34 41 35 42 void SemanticError::append( const std::string & msg ) { 36 errors.push_back( std::string( "Error: ") + msg );43 errors.emplace_back( error_str() + msg ); 37 44 } 38 45 … … 42 49 43 50 void SemanticError::print( std::ostream &os ) { 44 std::copy( errors.begin(), errors.end(), std::ostream_iterator< std::string >( os, "\n" ) ); 51 using std::to_string; 52 for(auto err : errors) { 53 os << to_string( err.location ) << err.description << '\n'; 54 } 55 } 56 57 void SemanticError::set_location( const CodeLocation& location ) { 58 errors.begin()->maybeSet( location ); 45 59 } 46 60
Note: See TracChangeset
for help on using the changeset viewer.