Support for diagnostics system.
This commit is contained in:
@@ -2,19 +2,22 @@
|
||||
#define ELOHIMSCRIPT_LEXER_HPP
|
||||
|
||||
#include <string_view>
|
||||
#include "../../Diagnostics/Diagnostics.hpp"
|
||||
#include "LexToken.hpp"
|
||||
|
||||
namespace ElohimScript::Parser {
|
||||
class Lexer {
|
||||
public:
|
||||
Lexer(const char* script) : _script(reinterpret_cast<const char8_t*>(script)) {}
|
||||
Lexer(const char8_t* script) : _script(script) {}
|
||||
Lexer(std::u8string_view script) : _script(script) {}
|
||||
Lexer(const char* script, Diagnostics::Diagnostics* diag)
|
||||
: Lexer(reinterpret_cast<const char8_t*>(script), diag) {}
|
||||
Lexer(const char8_t* script, Diagnostics::Diagnostics* diag) : _script(script), _diagnostics(diag) {}
|
||||
Lexer(std::u8string_view script, Diagnostics::Diagnostics* diag) : _script(script), _diagnostics(diag) {}
|
||||
const LexToken* Lex();
|
||||
|
||||
private:
|
||||
std::u8string_view _script;
|
||||
size_t _position = -1;
|
||||
Diagnostics::Diagnostics* _diagnostics;
|
||||
|
||||
inline char8_t Consume() {
|
||||
if (++_position >= _script.size()) {
|
||||
@@ -23,9 +26,7 @@ namespace ElohimScript::Parser {
|
||||
return _script[_position];
|
||||
}
|
||||
|
||||
inline void Progress(size_t steps = 1){
|
||||
_position += steps;
|
||||
}
|
||||
inline void Progress(size_t steps = 1) { _position += steps; }
|
||||
|
||||
inline char8_t Peek(size_t offset = 1) {
|
||||
auto pos = _position + offset;
|
||||
|
||||
Reference in New Issue
Block a user