Use block allocator for lexer.

This commit is contained in:
2020-10-04 22:21:20 +02:00
parent 0ce2feee06
commit 739e2e6f17
9 changed files with 206 additions and 143 deletions

View File

@@ -11,7 +11,6 @@ using namespace ElohimScript::Parser;
CHECK(diag.GetMessages().empty()); \
CHECK(token->GetKind() == LexTokenKind::symbol); \
CHECK(token->GetNext()->GetKind() == LexTokenKind::EndOfFile); \
delete token; \
}
KEYWORD_TEST("and", AndKeyword);
@@ -101,7 +100,6 @@ namespace doctest {
auto value = ((IdentifierToken*)token)->GetValue(); \
CHECK(value == std::u8string(reinterpret_cast<const char8_t*>(identifier))); \
CHECK(token->GetNext()->GetKind() == LexTokenKind::EndOfFile); \
delete token; \
}
IDENTIFIER_TEST("foobar");

View File

@@ -17,7 +17,6 @@ using namespace ElohimScript::Parser;
pos++; \
current = current->GetNext().get(); \
} \
delete token; \
}
LEX_TEST("1 + 1", LexTokenKind::IntegerLiteral, LexTokenKind::Whitespace, LexTokenKind::PlusSymbol,

View File

@@ -13,7 +13,6 @@ using namespace ElohimScript::Parser;
auto value = ((const IntegerLiteral*)token)->GetValue(); \
CHECK(value == (expected)); \
CHECK(token->GetNext()->GetKind() == LexTokenKind::EndOfFile); \
delete token; \
}
#define FLOAT_TEST(script, expected) \
@@ -26,7 +25,6 @@ using namespace ElohimScript::Parser;
auto value = ((const FloatLiteral*)token)->GetValue(); \
CHECK(value == (expected)); \
CHECK(token->GetNext()->GetKind() == LexTokenKind::EndOfFile); \
delete token; \
}
// Decimal lexing
@@ -72,11 +70,10 @@ INTEGER_TEST("0b110011", 51);
TEST_CASE("Lex invalid numerical base") {
ElohimScript::Diagnostics::Diagnostics diag;
auto lexer = Lexer("0f553", &diag);
const auto* token = lexer.Lex();
lexer.Lex();
const auto& messages = diag.GetMessages();
REQUIRE(messages.size() == 1);
CHECK(messages[0].GetType() == ElohimScript::Diagnostics::DiagnosticType::InvalidNumericalBase);
CHECK(messages[0].GetLevel() == ElohimScript::Diagnostics::DiagnosticLevel::Error);
CHECK(messages[0].GetSpan() == ElohimScript::TextSpan(0, 2));
delete token;
}

View File

@@ -13,7 +13,6 @@ using namespace ElohimScript::Parser;
auto value = ((const StringLiteral*)token)->GetValue(); \
CHECK(value == std::u8string(reinterpret_cast<const char8_t*>(str))); \
CHECK(token->GetNext()->GetKind() == LexTokenKind::EndOfFile); \
delete token; \
}
STRING_TEST("foo bar", "'");
@@ -34,5 +33,4 @@ bar""")",
CHECK(value == std::u8string(reinterpret_cast<const char8_t*>(R"(foo
bar)")));
CHECK(token->GetNext()->GetKind() == LexTokenKind::EndOfFile);
delete token;
}

View File

@@ -12,7 +12,6 @@ using namespace ElohimScript::Parser;
CHECK(diag.GetMessages().empty()); \
CHECK(token->GetKind() == LexTokenKind::symbol); \
CHECK(token->GetNext()->GetKind() == LexTokenKind::EndOfFile); \
delete token; \
}
SYMBOL_TEST("*", StarSymbol)
@@ -80,6 +79,5 @@ TEST_CASE("Lex whitespace") {
CHECK(diag.GetMessages().empty());
CHECK(token->GetKind() == LexTokenKind::Whitespace);
CHECK(token->GetNext()->GetKind() == LexTokenKind::EndOfFile);
delete token;
}
}