PorygonLang/src/Diagnostics/Diagnostics.hpp

45 lines
1.1 KiB
C++
Raw Normal View History

2019-05-21 11:56:08 +00:00
#ifndef PORYGONLANG_DIAGNOSTICS_HPP
#define PORYGONLANG_DIAGNOSTICS_HPP
#include <vector>
#include "DiagnosticSeverity.hpp"
#include "DiagnosticCode.hpp"
#include "Diagnostic.hpp"
using namespace std;
class Diagnostics {
bool _hasErrors;
vector<Diagnostic> _diagnostics;
public:
Diagnostics(){
_hasErrors = false;
}
void Log(DiagnosticSeverity severity, DiagnosticCode code, unsigned int start, unsigned int length){
_diagnostics.emplace_back(severity, code, start, length);
if (severity >= DiagnosticSeverity::Error){
_hasErrors = true;
}
}
void LogError(DiagnosticCode code, unsigned int start, unsigned int length){
Log(DiagnosticSeverity::Error, code, start, length);
}
void LogWarning(DiagnosticCode code, unsigned int start, unsigned int length){
Log(DiagnosticSeverity::Warning, code, start, length);
}
void LogInfo(DiagnosticCode code, unsigned int start, unsigned int length){
Log(DiagnosticSeverity::Info, code, start, length);
}
bool HasErrors(){
return _hasErrors;
}
};
#endif //PORYGONLANG_DIAGNOSTICS_HPP