1 | //
|
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
|
---|
3 | //
|
---|
4 | // The contents of this file are covered under the licence agreement in the
|
---|
5 | // file "LICENCE" distributed with Cforall.
|
---|
6 | //
|
---|
7 | // SemanticError.cc --
|
---|
8 | //
|
---|
9 | // Author : Richard C. Bilson
|
---|
10 | // Created On : Mon May 18 07:44:20 2015
|
---|
11 | // Last Modified By : Peter A. Buhr
|
---|
12 | // Last Modified On : Tue Aug 29 18:17:35 2017
|
---|
13 | // Update Count : 3
|
---|
14 | //
|
---|
15 |
|
---|
16 | #include <cstdio> // for fileno, stderr
|
---|
17 | #include <unistd.h> // for isatty
|
---|
18 | #include <iostream> // for basic_ostream, operator<<, ostream
|
---|
19 | #include <list> // for list, _List_iterator
|
---|
20 | #include <string> // for string, operator<<, operator+, to_string
|
---|
21 |
|
---|
22 | #include "Common/utility.h" // for to_string, CodeLocation (ptr only)
|
---|
23 | #include "SemanticError.h"
|
---|
24 |
|
---|
25 | SemanticError::SemanticError( CodeLocation location, std::string error ) {
|
---|
26 | append( location, error );
|
---|
27 | }
|
---|
28 |
|
---|
29 | void SemanticError::append( SemanticError &other ) {
|
---|
30 | errors.splice( errors.end(), other.errors );
|
---|
31 | }
|
---|
32 |
|
---|
33 | void SemanticError::append( CodeLocation location, const std::string & msg ) {
|
---|
34 | errors.emplace_back( location, msg );
|
---|
35 | }
|
---|
36 |
|
---|
37 | bool SemanticError::isEmpty() const {
|
---|
38 | return errors.empty();
|
---|
39 | }
|
---|
40 |
|
---|
41 | void SemanticError::print() {
|
---|
42 | using std::to_string;
|
---|
43 | for( auto err : errors ) {
|
---|
44 | std::cerr << bold() << err.location << error_str() << reset_font() << err.description << std::endl;
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|
48 | SemanticWarning::SemanticWarning( CodeLocation location, std::string msg ) {
|
---|
49 | std::cerr << bold() << location << warning_str() << reset_font() << msg << std::endl;
|
---|
50 | }
|
---|
51 |
|
---|
52 | // Local Variables: //
|
---|
53 | // tab-width: 4 //
|
---|
54 | // mode: c++ //
|
---|
55 | // compile-command: "make install" //
|
---|
56 | // End: //
|
---|