// // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // SemanticError.cc -- // // Author : Richard C. Bilson // Created On : Mon May 18 07:44:20 2015 // Last Modified By : Peter A. Buhr // Last Modified On : Tue May 19 07:21:25 2015 // Update Count : 1 // #include #include #include #include #include #include "SemanticError.h" SemanticError::SemanticError() { } SemanticError::SemanticError( std::string error ) { append( error ); } void SemanticError::append( SemanticError &other ) { errors.splice( errors.end(), other.errors ); } void SemanticError::append( const std::string & msg ) { using std::to_string; const std::string loc = location.linenumber >= 0 ? "At \"" + to_string(location) + "\" " : ""; errors.push_back( loc + "Error: " + msg ); } bool SemanticError::isEmpty() const { return errors.empty(); } void SemanticError::print( std::ostream &os ) { std::copy( errors.begin(), errors.end(), std::ostream_iterator< std::string >( os, "\n" ) ); } void SemanticError::set_location( const CodeLocation& location ) { this->location = location; using std::to_string; const std::string loc = location.linenumber >= 0 ? "At \"" + to_string(location) + "\" " : ""; auto& error = *errors.begin(); error.insert( 0, loc.c_str()); } // Local Variables: // // tab-width: 4 // // mode: c++ // // compile-command: "make install" // // End: //