From 7d1b8ac13faf80ed56b37243480d097059da5aab Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 25 May 2021 20:58:43 -0400 Subject: JSON Lexing and string encoding/decoding (#1858) * #include an absolute path didn't work - because paths were taken to always be relative. * WIP Json lexer. * Check JSON Lex with unit test * Add JSON escaping/unescaping of strings. * Big fix encoding/decoding. * Fix typo in JSON diagnostics. * Fix typo. * Better float testing. --- source/compiler-core/slang-json-diagnostics.cpp | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 source/compiler-core/slang-json-diagnostics.cpp (limited to 'source/compiler-core/slang-json-diagnostics.cpp') diff --git a/source/compiler-core/slang-json-diagnostics.cpp b/source/compiler-core/slang-json-diagnostics.cpp new file mode 100644 index 000000000..1d35e8faf --- /dev/null +++ b/source/compiler-core/slang-json-diagnostics.cpp @@ -0,0 +1,33 @@ +// slang-json-diagnostics.cpp +#include "slang-json-diagnostics.h" + +namespace Slang { + +namespace JSONDiagnostics +{ +#define DIAGNOSTIC(id, severity, name, messageFormat) const DiagnosticInfo name = { id, Severity::severity, #name, messageFormat }; +#include "slang-json-diagnostic-defs.h" +#undef DIAGNOSTIC +} + +static const DiagnosticInfo* const kJSONDiagnostics[] = +{ +#define DIAGNOSTIC(id, severity, name, messageFormat) &JSONDiagnostics::name, +#include "slang-json-diagnostic-defs.h" +#undef DIAGNOSTIC +}; + +static DiagnosticsLookup* _newJSONDiagnosticsLookup() +{ + auto lookup = new DiagnosticsLookup; + lookup->add(kJSONDiagnostics, SLANG_COUNT_OF(kJSONDiagnostics)); + return lookup; +} + +DiagnosticsLookup* getJSONDiagnosticsLookup() +{ + static RefPtr s_lookup = _newJSONDiagnosticsLookup(); + return s_lookup; +} + +} // namespace Slang -- cgit v1.2.3