Move Diagnostics to separate namespace
This commit is contained in:
@@ -5,33 +5,35 @@
|
||||
#include "DiagnosticSeverity.hpp"
|
||||
#include "DiagnosticCode.hpp"
|
||||
|
||||
class Diagnostic{
|
||||
DiagnosticSeverity _severity;
|
||||
DiagnosticCode _code;
|
||||
unsigned int _start;
|
||||
unsigned int _length;
|
||||
public:
|
||||
Diagnostic(DiagnosticSeverity severity, DiagnosticCode code, unsigned int start, unsigned int length){
|
||||
_severity = severity;
|
||||
_code = code;
|
||||
_start = start;
|
||||
_length = length;
|
||||
}
|
||||
namespace Porygon::Diagnostics {
|
||||
class Diagnostic {
|
||||
DiagnosticSeverity _severity;
|
||||
DiagnosticCode _code;
|
||||
unsigned int _start;
|
||||
unsigned int _length;
|
||||
public:
|
||||
Diagnostic(DiagnosticSeverity severity, DiagnosticCode code, unsigned int start, unsigned int length) {
|
||||
_severity = severity;
|
||||
_code = code;
|
||||
_start = start;
|
||||
_length = length;
|
||||
}
|
||||
|
||||
DiagnosticSeverity GetSeverity(){
|
||||
return _severity;
|
||||
}
|
||||
DiagnosticCode GetCode(){
|
||||
return _code;
|
||||
}
|
||||
DiagnosticSeverity GetSeverity() {
|
||||
return _severity;
|
||||
}
|
||||
|
||||
unsigned int GetStartPosition(){
|
||||
return _start;
|
||||
}
|
||||
DiagnosticCode GetCode() {
|
||||
return _code;
|
||||
}
|
||||
|
||||
unsigned int GetLength(){
|
||||
return _length;
|
||||
}
|
||||
};
|
||||
unsigned int GetStartPosition() {
|
||||
return _start;
|
||||
}
|
||||
|
||||
unsigned int GetLength() {
|
||||
return _length;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif //PORYGONLANG_DIAGNOSTIC_HPP
|
||||
|
||||
@@ -2,29 +2,30 @@
|
||||
#ifndef PORYGONLANG_DIAGNOSTICCODE_HPP
|
||||
#define PORYGONLANG_DIAGNOSTICCODE_HPP
|
||||
|
||||
enum class DiagnosticCode{
|
||||
// Lex diagnostics
|
||||
UnexpectedCharacter,
|
||||
InvalidStringControlCharacter,
|
||||
namespace Porygon::Diagnostics {
|
||||
enum class DiagnosticCode {
|
||||
// Lex diagnostics
|
||||
UnexpectedCharacter,
|
||||
InvalidStringControlCharacter,
|
||||
|
||||
// Parse diagnostics
|
||||
UnexpectedToken,
|
||||
|
||||
// Bind diagnostics
|
||||
NoBinaryOperationFound,
|
||||
NoUnaryOperationFound,
|
||||
CantAssignVariable,
|
||||
VariableNotFound,
|
||||
ExpressionIsNotAFunction,
|
||||
ParameterCountMismatch,
|
||||
ParameterTypeMismatch,
|
||||
CantIndex,
|
||||
InvalidReturnType,
|
||||
ConditionNotABool,
|
||||
InvalidTableValueType,
|
||||
InvalidTypeName,
|
||||
UserDataFieldNoGetter,
|
||||
UserDataFieldNoSetter
|
||||
};
|
||||
// Parse diagnostics
|
||||
UnexpectedToken,
|
||||
|
||||
// Bind diagnostics
|
||||
NoBinaryOperationFound,
|
||||
NoUnaryOperationFound,
|
||||
CantAssignVariable,
|
||||
VariableNotFound,
|
||||
ExpressionIsNotAFunction,
|
||||
ParameterCountMismatch,
|
||||
ParameterTypeMismatch,
|
||||
CantIndex,
|
||||
InvalidReturnType,
|
||||
ConditionNotABool,
|
||||
InvalidTableValueType,
|
||||
InvalidTypeName,
|
||||
UserDataFieldNoGetter,
|
||||
UserDataFieldNoSetter
|
||||
};
|
||||
}
|
||||
#endif //PORYGONLANG_DIAGNOSTICCODE_HPP
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
#ifndef PORYGONLANG_DIAGNOSTICSEVERITY_HPP
|
||||
#define PORYGONLANG_DIAGNOSTICSEVERITY_HPP
|
||||
|
||||
enum class DiagnosticSeverity{
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
};
|
||||
namespace Porygon::Diagnostics {
|
||||
enum class DiagnosticSeverity {
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
};
|
||||
}
|
||||
|
||||
#endif //PORYGONLANG_DIAGNOSTICSEVERITY_HPP
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "DiagnosticsHolder.hpp"
|
||||
|
||||
using namespace Porygon::Diagnostics;
|
||||
vector<Diagnostic> DiagnosticsHolder::GetDiagnostics() {
|
||||
return _diagnostics;
|
||||
}
|
||||
|
||||
@@ -9,31 +9,35 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
class DiagnosticsHolder {
|
||||
bool _hasErrors;
|
||||
vector<Diagnostic> _diagnostics;
|
||||
public:
|
||||
DiagnosticsHolder(){
|
||||
_hasErrors = false;
|
||||
}
|
||||
namespace Porygon::Diagnostics {
|
||||
class DiagnosticsHolder {
|
||||
bool _hasErrors;
|
||||
vector<Diagnostic> _diagnostics;
|
||||
public:
|
||||
DiagnosticsHolder() {
|
||||
_hasErrors = false;
|
||||
}
|
||||
|
||||
~DiagnosticsHolder(){
|
||||
_diagnostics.clear();
|
||||
}
|
||||
~DiagnosticsHolder() {
|
||||
_diagnostics.clear();
|
||||
}
|
||||
|
||||
void Log(DiagnosticSeverity severity, DiagnosticCode code, unsigned int start, unsigned int length);
|
||||
void LogError(DiagnosticCode code, unsigned int start, unsigned int length);
|
||||
void LogWarning(DiagnosticCode code, unsigned int start, unsigned int length);
|
||||
void LogInfo(DiagnosticCode code, unsigned int start, unsigned int length);
|
||||
void Log(DiagnosticSeverity severity, DiagnosticCode code, unsigned int start, unsigned int length);
|
||||
|
||||
bool HasErrors();
|
||||
void LogError(DiagnosticCode code, unsigned int start, unsigned int length);
|
||||
|
||||
vector<Diagnostic> GetDiagnostics();
|
||||
void LogWarning(DiagnosticCode code, unsigned int start, unsigned int length);
|
||||
|
||||
int DiagnosticsCount();
|
||||
void LogInfo(DiagnosticCode code, unsigned int start, unsigned int length);
|
||||
|
||||
Diagnostic* GetDiagnosticAt(int position);
|
||||
};
|
||||
bool HasErrors();
|
||||
|
||||
vector<Diagnostic> GetDiagnostics();
|
||||
|
||||
int DiagnosticsCount();
|
||||
|
||||
Diagnostic *GetDiagnosticAt(int position);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //PORYGONLANG_DIAGNOSTICSHOLDER_HPP
|
||||
|
||||
Reference in New Issue
Block a user