Support adding filename to diagnostic.
This commit is contained in:
@@ -9,14 +9,16 @@
|
||||
namespace ElohimScript::Parser {
|
||||
class Lexer {
|
||||
public:
|
||||
Lexer(const char* script, Diagnostics::Diagnostics* diag)
|
||||
: Lexer(reinterpret_cast<const char8_t*>(script), diag) {}
|
||||
Lexer(const char8_t* script, Diagnostics::Diagnostics* diag) : Lexer(std::u8string_view(script), diag) {}
|
||||
Lexer(std::u8string_view script, Diagnostics::Diagnostics* diag)
|
||||
: _script(script), _scriptLength(script.size()), _diagnostics(diag) {}
|
||||
Lexer(const char* scriptName, const char* script, Diagnostics::Diagnostics* diag)
|
||||
: Lexer(reinterpret_cast<const char8_t*>(scriptName), reinterpret_cast<const char8_t*>(script), diag) {}
|
||||
Lexer(const char8_t* scriptName, const char8_t* script, Diagnostics::Diagnostics* diag)
|
||||
: Lexer(std::u8string_view(scriptName), std::u8string_view(script), diag) {}
|
||||
Lexer(std::u8string_view scriptName, std::u8string_view script, Diagnostics::Diagnostics* diag)
|
||||
: _scriptName(scriptName), _script(script), _scriptLength(script.size()), _diagnostics(diag) {}
|
||||
const LexToken* Lex();
|
||||
|
||||
private:
|
||||
std::u8string_view _scriptName;
|
||||
std::u8string_view _script;
|
||||
size_t _position = -1;
|
||||
size_t _scriptLength;
|
||||
@@ -56,6 +58,10 @@ namespace ElohimScript::Parser {
|
||||
template <class T, class... parameters> inline T* Create(parameters... args) {
|
||||
return _allocator.Create<T>(args...);
|
||||
}
|
||||
|
||||
inline void LogError(Diagnostics::DiagnosticType type, TextSpan span) {
|
||||
_diagnostics->LogError(type, _scriptName, span);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user