Fixes bug in identifier/keyword parsing, adds lexer integration tests.
This commit is contained in:
@@ -466,9 +466,9 @@ namespace ElohimScript::Parser {
|
||||
while (IsAlphaNumericalOrUnderscore(Peek(offset))) {
|
||||
offset++;
|
||||
}
|
||||
auto str = _script.substr(_position, offset);
|
||||
Progress(offset);
|
||||
switch (Hash(str.data())) {
|
||||
auto str = std::u8string(_script.substr(start, offset));
|
||||
Progress(offset - 1);
|
||||
switch (Hash(str.c_str())) {
|
||||
case Hash(u8"and"): return new LexTokenImpl<LexTokenKind::AndKeyword>(TextSpan(start, _position));
|
||||
case Hash(u8"abstract"): return new LexTokenImpl<LexTokenKind::AbstractKeyword>(TextSpan(start, _position));
|
||||
case Hash(u8"auto"): return new LexTokenImpl<LexTokenKind::AutoKeyword>(TextSpan(start, _position));
|
||||
@@ -537,7 +537,7 @@ namespace ElohimScript::Parser {
|
||||
case Hash(u8"while"): return new LexTokenImpl<LexTokenKind::WhileKeyword>(TextSpan(start, _position));
|
||||
case Hash(u8"xor"): return new LexTokenImpl<LexTokenKind::XorKeyword>(TextSpan(start, _position));
|
||||
|
||||
default: return new IdentifierToken(TextSpan(start, _position), std::u8string(str));
|
||||
default: return new IdentifierToken(TextSpan(start, _position), str);
|
||||
}
|
||||
}
|
||||
bool Lexer::IsAlphaNumericalOrUnderscore(char8_t c) {
|
||||
|
||||
Reference in New Issue
Block a user