-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdiagnostics.cpp
More file actions
45 lines (40 loc) · 1.51 KB
/
diagnostics.cpp
File metadata and controls
45 lines (40 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include "diagnostics.hpp"
#include "diagnose/diagnostics.hpp"
diagnose::manager& doir::diagnostics() {
static diagnose::manager diagnostics;
return diagnostics;
}
diagnose::diagnostic doir::generate_diagnostic(doir::diagnostic_type type, diagnose::source_location::detailed location, std::string_view source, std::string_view path) {
diagnostics().register_source(path, source);
diagnose::diagnostic out;
out.code = (size_t)type;
out.location = location;
switch(type){
// Errors
break; case diagnostic_type::LanguageChangeNotSupported:
out.kind = diagnose::diagnostic::error;
out.message = "Changing languages is not supported in the prototype";
break; case diagnostic_type::FileDoesNotExist:
out.kind = diagnose::diagnostic::error;
out.message = "File does not exist";
break; case diagnostic_type::NumberingStartsAt1:
out.kind = diagnose::diagnostic::error;
out.message = "Numbering starts at 1";
break; case diagnostic_type::NumberingOutOfOrder:
out.kind = diagnose::diagnostic::error;
out.message = "Numbering out of order";
break; case diagnostic_type::AliasNotAllowed:
out.kind = diagnose::diagnostic::error;
out.message = "Alias not allowed";
break; case diagnostic_type::InvalidIdentifier:
out.kind = diagnose::diagnostic::error;
out.message = "Invalid identifier";
// Warnings
break; case diagnostic_type::CompilerNamespaceReserved:
out.kind = diagnose::diagnostic::warning;
out.message = "`compiler` namespace reserved";
}
return out;
}