MalachScript/src/Diagnostics/DiagnosticTypeEN_US.hpp

33 lines
1.5 KiB
C++

#ifndef MALACHSCRIPT_DIAGNOSTICTYPEEN_US_HPP
#define MALACHSCRIPT_DIAGNOSTICTYPEEN_US_HPP
#include "../../extern/format.hpp"
#include "Diagnostic.hpp"
namespace MalachScript::Diagnostics {
class DiagnosticTypeHelper {
public:
static std::string ToEnglishString(const Diagnostic* diag) {
switch (diag->GetType()) {
case DiagnosticType::UnknownCharacter:
return util::Format("Unknown character: '{0}'", diag->GetFormats());
case DiagnosticType::ExpectedEndOfString:
return util::Format("Expected end of string, found {0}", diag->GetFormats());
case DiagnosticType::UnexpectedToken:
if (diag->GetFormats().size() == 1) {
return util::Format("Unexpected Token: '{0}'", diag->GetFormats());
} else if (diag->GetFormats().size() == 2) {
return util::Format("Unexpected Token. Expected: '{0}', but found '{-1}'", diag->GetFormats());
} else if (diag->GetFormats().size() > 2) {
return util::Format("Unexpected Token. Expected any of: '{0..-2}', but found '{-1}'",
diag->GetFormats());
}
case DiagnosticType::DoubleProperty: return "Property block found twice.";
}
return std::to_string((uint8_t)diag->GetType());
}
};
}
#endif // MALACHSCRIPT_DIAGNOSTICTYPEEN_US_HPP