Changes in src/Common/SemanticError.h [9ed4f94:21f0aa8]
- File:
-
- 1 edited
-
src/Common/SemanticError.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/SemanticError.h
r9ed4f94 r21f0aa8 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T ue Aug 29 22:03:36201713 // Update Count : 1711 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Aug 17 14:01:00 2017 13 // Update Count : 7 14 14 // 15 15 16 16 #pragma once 17 17 18 #include <exception> // for exception 19 #include <iostream> // for ostream 20 #include <list> // for list 21 #include <string> // for string 22 #include <unistd.h> // for isatty 18 #include <exception> // for exception 19 #include <iostream> // for ostream 20 #include <list> // for list 21 #include <string> // for string 23 22 24 #include "CodeLocation.h" // for CodeLocation, toString23 #include "CodeLocation.h" // for CodeLocation, toString 25 24 26 25 struct error { … … 29 28 30 29 error() = default; 31 error( const std::string & str ) : description( str ) {}30 error( const std::string& str ) : description( str ) {} 32 31 33 void maybeSet( const CodeLocation & location ) {32 void maybeSet( const CodeLocation& location ) { 34 33 if( this->location.linenumber < 0 ) { 35 34 this->location = location; … … 42 41 SemanticError(); 43 42 SemanticError( std::string error ); 44 template< typename T > SemanticError( const std::string & error, const T *obj );43 template< typename T > SemanticError( const std::string &error, const T *obj ); 45 44 ~SemanticError() throw() {} 46 45 47 static inline const std::string & error_str() { 48 static std::string str = isatty( STDERR_FILENO ) ? "\e[31merror:\e[39m " : "error: "; 49 return str; 50 } 51 52 void append( SemanticError & other ); 46 void append( SemanticError &other ); 53 47 void append( const std::string & ); 54 48 bool isEmpty() const; 55 void print( std::ostream & os );49 void print( std::ostream &os ); 56 50 57 void set_location( const CodeLocation & location );58 // constructs an exception using the given message and the printed representation of the obj (T must have a print59 // method)51 void set_location( const CodeLocation& location ); 52 // constructs an exception using the given message and the printed 53 // representation of the obj (T must have a print method) 60 54 private: 61 55 std::list< error > errors; … … 63 57 64 58 template< typename T > 65 SemanticError::SemanticError( const std::string & error, const T *obj ) {59 SemanticError::SemanticError( const std::string &error, const T *obj ) { 66 60 append( toString( error, obj ) ); 67 61 }
Note:
See TracChangeset
for help on using the changeset viewer.