From f299d5183f54e8f8118c2ae23350605bdfff9d6b Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Mon, 5 Oct 2020 17:45:00 +0200 Subject: [PATCH] Renames project. --- CMakeLists.txt | 10 ++-- src/Diagnostics/Diagnostic.hpp | 8 +-- src/Diagnostics/DiagnosticLevel.hpp | 8 +-- src/Diagnostics/DiagnosticType.hpp | 8 +-- src/Diagnostics/Diagnostics.hpp | 8 +-- src/Parser/Expressions/ParsedExperssion.hpp | 8 +++ src/Parser/Lexer/LexResult.hpp | 8 +-- src/Parser/Lexer/LexToken.hpp | 8 +-- src/Parser/Lexer/LexTokenKind.hpp | 8 +-- src/Parser/Lexer/Lexer.cpp | 2 +- src/Parser/Lexer/Lexer.hpp | 8 +-- src/Parser/Lexer/NumericalLexers.hpp | 6 +-- src/Parser/Parser.cpp | 26 ++++++++++ src/Parser/Parser.hpp | 33 ++++++++++++ src/Parser/Statements/ParsedStatement.hpp | 51 +++++++++++++++++++ src/Parser/Statements/ParsedStatementKind.hpp | 12 +++++ src/TextSpan.hpp | 8 +-- src/Utils/MemoryAllocator.hpp | 8 +-- tests/LexerTests/IdentifierLexTests.cpp | 6 +-- tests/LexerTests/LexerIntegrationTests.cpp | 4 +- tests/LexerTests/NumericalLexTests.cpp | 14 ++--- tests/LexerTests/StringLexTests.cpp | 6 +-- tests/LexerTests/SymbolLexTests.cpp | 6 +-- 23 files changed, 197 insertions(+), 67 deletions(-) create mode 100644 src/Parser/Expressions/ParsedExperssion.hpp create mode 100644 src/Parser/Parser.cpp create mode 100644 src/Parser/Parser.hpp create mode 100644 src/Parser/Statements/ParsedStatement.hpp create mode 100644 src/Parser/Statements/ParsedStatementKind.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 88e062c..3942f1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.17) -project(ElohimScript) +project(MalachScript) # Enable all warnings, and make them error when occurring. add_compile_options(-Wall -Wextra -Werror) @@ -18,16 +18,16 @@ if (NOT WINDOWS) endif () file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp") -add_library(ElohimScript SHARED ${SRC_FILES}) +add_library(MalachScript SHARED ${SRC_FILES}) if (TESTS) # Create Test executable file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp") - add_executable(ElohimScriptTests ${TEST_FILES} extern/doctest.hpp) - target_link_libraries(ElohimScriptTests PUBLIC ElohimScript) + add_executable(MalachScriptTests ${TEST_FILES} extern/doctest.hpp) + target_link_libraries(MalachScriptTests PUBLIC MalachScript) # Add a definition for the test library - target_compile_definitions(ElohimScriptTests PRIVATE TESTS_BUILD) + target_compile_definitions(MalachScriptTests PRIVATE TESTS_BUILD) endif () diff --git a/src/Diagnostics/Diagnostic.hpp b/src/Diagnostics/Diagnostic.hpp index 318e6df..e73ba59 100644 --- a/src/Diagnostics/Diagnostic.hpp +++ b/src/Diagnostics/Diagnostic.hpp @@ -1,11 +1,11 @@ -#ifndef ELOHIMSCRIPT_DIAGNOSTIC_HPP -#define ELOHIMSCRIPT_DIAGNOSTIC_HPP +#ifndef MALACHSCRIPT_DIAGNOSTIC_HPP +#define MALACHSCRIPT_DIAGNOSTIC_HPP #include "../TextSpan.hpp" #include "DiagnosticLevel.hpp" #include "DiagnosticType.hpp" -namespace ElohimScript::Diagnostics { +namespace MalachScript::Diagnostics { class Diagnostic { DiagnosticLevel _level; DiagnosticType _type; @@ -24,4 +24,4 @@ namespace ElohimScript::Diagnostics { }; } -#endif // ELOHIMSCRIPT_DIAGNOSTIC_HPP +#endif // MALACHSCRIPT_DIAGNOSTIC_HPP diff --git a/src/Diagnostics/DiagnosticLevel.hpp b/src/Diagnostics/DiagnosticLevel.hpp index 382ce9c..735b078 100644 --- a/src/Diagnostics/DiagnosticLevel.hpp +++ b/src/Diagnostics/DiagnosticLevel.hpp @@ -1,8 +1,8 @@ -#ifndef ELOHIMSCRIPT_DIAGNOSTICLEVEL_HPP -#define ELOHIMSCRIPT_DIAGNOSTICLEVEL_HPP +#ifndef MALACHSCRIPT_DIAGNOSTICLEVEL_HPP +#define MALACHSCRIPT_DIAGNOSTICLEVEL_HPP #include -namespace ElohimScript::Diagnostics { +namespace MalachScript::Diagnostics { enum class DiagnosticLevel : uint8_t { Trace, Information, @@ -12,4 +12,4 @@ namespace ElohimScript::Diagnostics { }; } -#endif // ELOHIMSCRIPT_DIAGNOSTICLEVEL_HPP +#endif // MALACHSCRIPT_DIAGNOSTICLEVEL_HPP diff --git a/src/Diagnostics/DiagnosticType.hpp b/src/Diagnostics/DiagnosticType.hpp index f619ce1..7ad1927 100644 --- a/src/Diagnostics/DiagnosticType.hpp +++ b/src/Diagnostics/DiagnosticType.hpp @@ -1,8 +1,8 @@ -#ifndef ELOHIMSCRIPT_DIAGNOSTICTYPE_HPP -#define ELOHIMSCRIPT_DIAGNOSTICTYPE_HPP +#ifndef MALACHSCRIPT_DIAGNOSTICTYPE_HPP +#define MALACHSCRIPT_DIAGNOSTICTYPE_HPP #include -namespace ElohimScript::Diagnostics { +namespace MalachScript::Diagnostics { enum class DiagnosticType : uint8_t { UnknownToken, InvalidNumericalBase, ExpectedEndOfString }; class DiagnosticTypeHelper { @@ -17,4 +17,4 @@ namespace ElohimScript::Diagnostics { }; } -#endif // ELOHIMSCRIPT_DIAGNOSTICTYPE_HPP +#endif // MALACHSCRIPT_DIAGNOSTICTYPE_HPP diff --git a/src/Diagnostics/Diagnostics.hpp b/src/Diagnostics/Diagnostics.hpp index 6afae3c..1d171dc 100644 --- a/src/Diagnostics/Diagnostics.hpp +++ b/src/Diagnostics/Diagnostics.hpp @@ -1,10 +1,10 @@ -#ifndef ELOHIMSCRIPT_DIAGNOSTICS_HPP -#define ELOHIMSCRIPT_DIAGNOSTICS_HPP +#ifndef MALACHSCRIPT_DIAGNOSTICS_HPP +#define MALACHSCRIPT_DIAGNOSTICS_HPP #include #include "Diagnostic.hpp" -namespace ElohimScript::Diagnostics { +namespace MalachScript::Diagnostics { class Diagnostics { std::vector _messages; @@ -32,4 +32,4 @@ namespace ElohimScript::Diagnostics { }; } -#endif // ELOHIMSCRIPT_DIAGNOSTICS_HPP +#endif // MALACHSCRIPT_DIAGNOSTICS_HPP diff --git a/src/Parser/Expressions/ParsedExperssion.hpp b/src/Parser/Expressions/ParsedExperssion.hpp new file mode 100644 index 0000000..22c3d3d --- /dev/null +++ b/src/Parser/Expressions/ParsedExperssion.hpp @@ -0,0 +1,8 @@ +#ifndef MALACHSCRIPT_PARSEDEXPERSSION_HPP +#define MALACHSCRIPT_PARSEDEXPERSSION_HPP + +namespace MalachScript::Parser{ + class ParsedExpression{}; +} + +#endif // MALACHSCRIPT_PARSEDEXPERSSION_HPP diff --git a/src/Parser/Lexer/LexResult.hpp b/src/Parser/Lexer/LexResult.hpp index 6c6693c..3254c3b 100644 --- a/src/Parser/Lexer/LexResult.hpp +++ b/src/Parser/Lexer/LexResult.hpp @@ -1,8 +1,8 @@ -#ifndef ELOHIMSCRIPT_LEXRESULT_HPP -#define ELOHIMSCRIPT_LEXRESULT_HPP +#ifndef MALACHSCRIPT_LEXRESULT_HPP +#define MALACHSCRIPT_LEXRESULT_HPP #include "LexToken.hpp" -namespace ElohimScript::Parser { +namespace MalachScript::Parser { class LexResult { public: LexResult(const LexToken* first, const uint8_t* memoryMap) : _first(first), _memoryMap(memoryMap) {} @@ -16,4 +16,4 @@ namespace ElohimScript::Parser { }; } -#endif // ELOHIMSCRIPT_LEXRESULT_HPP +#endif // MALACHSCRIPT_LEXRESULT_HPP diff --git a/src/Parser/Lexer/LexToken.hpp b/src/Parser/Lexer/LexToken.hpp index 566ae80..dfea5d4 100644 --- a/src/Parser/Lexer/LexToken.hpp +++ b/src/Parser/Lexer/LexToken.hpp @@ -1,11 +1,11 @@ -#ifndef ELOHIMSCRIPT_LEXTOKEN_HPP -#define ELOHIMSCRIPT_LEXTOKEN_HPP +#ifndef MALACHSCRIPT_LEXTOKEN_HPP +#define MALACHSCRIPT_LEXTOKEN_HPP #include #include #include "LexTokenKind.hpp" -namespace ElohimScript::Parser { +namespace MalachScript::Parser { class LexToken { friend class Lexer; @@ -62,4 +62,4 @@ namespace ElohimScript::Parser { }; } -#endif // ELOHIMSCRIPT_LEXTOKEN_HPP +#endif // MALACHSCRIPT_LEXTOKEN_HPP diff --git a/src/Parser/Lexer/LexTokenKind.hpp b/src/Parser/Lexer/LexTokenKind.hpp index f0f7625..0fb977f 100644 --- a/src/Parser/Lexer/LexTokenKind.hpp +++ b/src/Parser/Lexer/LexTokenKind.hpp @@ -1,8 +1,8 @@ -#ifndef ELOHIMSCRIPT_LEXTOKENKIND_HPP -#define ELOHIMSCRIPT_LEXTOKENKIND_HPP +#ifndef MALACHSCRIPT_LEXTOKENKIND_HPP +#define MALACHSCRIPT_LEXTOKENKIND_HPP #include -namespace ElohimScript::Parser { +namespace MalachScript::Parser { enum class LexTokenKind : uint8_t { Unknown, EndOfFile, @@ -136,4 +136,4 @@ namespace ElohimScript::Parser { }; } -#endif // ELOHIMSCRIPT_LEXTOKENKIND_HPP +#endif // MALACHSCRIPT_LEXTOKENKIND_HPP diff --git a/src/Parser/Lexer/Lexer.cpp b/src/Parser/Lexer/Lexer.cpp index b8042aa..dc17214 100644 --- a/src/Parser/Lexer/Lexer.cpp +++ b/src/Parser/Lexer/Lexer.cpp @@ -3,7 +3,7 @@ #include #include "NumericalLexers.hpp" -namespace ElohimScript::Parser { +namespace MalachScript::Parser { const LexToken* Lexer::Lex() { auto* first = LexNext(); if (first->GetKind() == LexTokenKind::EndOfFile) { diff --git a/src/Parser/Lexer/Lexer.hpp b/src/Parser/Lexer/Lexer.hpp index d416229..b243b5d 100644 --- a/src/Parser/Lexer/Lexer.hpp +++ b/src/Parser/Lexer/Lexer.hpp @@ -1,12 +1,12 @@ -#ifndef ELOHIMSCRIPT_LEXER_HPP -#define ELOHIMSCRIPT_LEXER_HPP +#ifndef MALACHSCRIPT_LEXER_HPP +#define MALACHSCRIPT_LEXER_HPP #include #include "../../Diagnostics/Diagnostics.hpp" #include "../../Utils/MemoryAllocator.hpp" #include "LexToken.hpp" -namespace ElohimScript::Parser { +namespace MalachScript::Parser { class Lexer { public: Lexer(const char* scriptName, const char* script, Diagnostics::Diagnostics* diag) @@ -65,4 +65,4 @@ namespace ElohimScript::Parser { }; } -#endif // ELOHIMSCRIPT_LEXER_HPP +#endif // MALACHSCRIPT_LEXER_HPP diff --git a/src/Parser/Lexer/NumericalLexers.hpp b/src/Parser/Lexer/NumericalLexers.hpp index 764051e..8335dc7 100644 --- a/src/Parser/Lexer/NumericalLexers.hpp +++ b/src/Parser/Lexer/NumericalLexers.hpp @@ -1,5 +1,5 @@ -#ifndef ELOHIMSCRIPT_NUMERICALLEXERS_HPP -#define ELOHIMSCRIPT_NUMERICALLEXERS_HPP +#ifndef MALACHSCRIPT_NUMERICALLEXERS_HPP +#define MALACHSCRIPT_NUMERICALLEXERS_HPP #include @@ -8,4 +8,4 @@ uint8_t LexHexadecimalValue(char8_t c); uint8_t LexOctalValue(char8_t c); uint8_t LexBinaryValue(char8_t c); -#endif // ELOHIMSCRIPT_NUMERICALLEXERS_HPP +#endif // MALACHSCRIPT_NUMERICALLEXERS_HPP diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp new file mode 100644 index 0000000..c8c87ed --- /dev/null +++ b/src/Parser/Parser.cpp @@ -0,0 +1,26 @@ +#include "Parser.hpp" + +namespace MalachScript::Parser { + ParsedScriptStatement* Parser::Parse() { + std::vector statements(32); + size_t current = 0; + while (true) { + auto next = this->Consume(); + if (next->GetKind() == LexTokenKind::EndOfFile) { + break; + } + statements[current] = this->ParseStatement(next); + current++; + } + statements.resize(current); + auto end = 0; + if (current > 0) { + end = statements.back()->GetSpan().GetEnd(); + } + const auto* block = new ParsedBlockStatement(TextSpan(0, end), statements); + return new ParsedScriptStatement(block); + } + const ParsedStatement* Parser::ParseStatement(const LexToken* token) { + // If modifier (shared, external, private, protected, etc) push to buffer, continue + } +} diff --git a/src/Parser/Parser.hpp b/src/Parser/Parser.hpp new file mode 100644 index 0000000..d3e2e4a --- /dev/null +++ b/src/Parser/Parser.hpp @@ -0,0 +1,33 @@ +#ifndef MALACHSCRIPT_PARSER_HPP +#define MALACHSCRIPT_PARSER_HPP + +#include "Lexer/LexToken.hpp" +#include "Statements/ParsedStatement.hpp" +namespace MalachScript::Parser { + class Parser { + public: + Parser(const LexToken* firstToken) : _currentToken(firstToken) {} + ParsedScriptStatement* Parse(); + + private: + const LexToken* _currentToken; + inline const LexToken* Peek() { + if (_currentToken->GetKind() == LexTokenKind::EndOfFile) { + return _currentToken; + } + return _currentToken->GetNext().get(); + } + + inline const LexToken* Consume() { + if (_currentToken->GetKind() == LexTokenKind::EndOfFile) { + return _currentToken; + } + _currentToken = _currentToken->GetNext().get(); + return _currentToken; + } + + const ParsedStatement* ParseStatement(const LexToken* token); + }; +} + +#endif // MALACHSCRIPT_PARSER_HPP diff --git a/src/Parser/Statements/ParsedStatement.hpp b/src/Parser/Statements/ParsedStatement.hpp new file mode 100644 index 0000000..e62bc7e --- /dev/null +++ b/src/Parser/Statements/ParsedStatement.hpp @@ -0,0 +1,51 @@ +#ifndef MALACHSCRIPT_PARSEDSTATEMENT_HPP +#define MALACHSCRIPT_PARSEDSTATEMENT_HPP + +#include +#include "../../TextSpan.hpp" +#include "ParsedStatementKind.hpp" +namespace MalachScript::Parser { + class ParsedStatement { + TextSpan _span; + + public: + ParsedStatement(TextSpan span) : _span(span) {} + [[nodiscard]] virtual ParsedStatementKind GetKind() const noexcept = 0; + [[nodiscard]] inline const TextSpan& GetSpan() const noexcept { return _span; } + }; + + template class ParsedStatementImpl : public ParsedStatement { + public: + ParsedStatementImpl(TextSpan span) : ParsedStatement(span) {} + [[nodiscard]] inline ParsedStatementKind GetKind() const noexcept override { return kind; } + }; + + class ParsedBlockStatement : public ParsedStatementImpl { + std::vector> _statements; + + public: + ParsedBlockStatement(TextSpan span, const std::vector& statements) + : ParsedStatementImpl(span), _statements(statements.size()) { + for (size_t i = 0; i < statements.size(); i++) + _statements[i] = std::unique_ptr(statements[i]); + } + + [[nodiscard]] inline const std::vector>& GetStatements() const noexcept { + return _statements; + } + }; + + class ParsedScriptStatement : public ParsedStatementImpl { + std::unique_ptr _block; + + public: + ParsedScriptStatement(const ParsedBlockStatement* block) + : ParsedStatementImpl(block->GetSpan()), _block(block) {} + + [[nodiscard]] inline const std::unique_ptr& GetBlock() const noexcept { + return _block; + } + }; +} + +#endif // MALACHSCRIPT_PARSEDSTATEMENT_HPP diff --git a/src/Parser/Statements/ParsedStatementKind.hpp b/src/Parser/Statements/ParsedStatementKind.hpp new file mode 100644 index 0000000..7a8bb22 --- /dev/null +++ b/src/Parser/Statements/ParsedStatementKind.hpp @@ -0,0 +1,12 @@ +#ifndef MALACHSCRIPT_PARSEDSTATEMENTKIND_HPP +#define MALACHSCRIPT_PARSEDSTATEMENTKIND_HPP + +namespace MalachScript::Parser { + enum class ParsedStatementKind{ + Unknown, + Block, + Script, + }; +} + +#endif // MALACHSCRIPT_PARSEDSTATEMENTKIND_HPP diff --git a/src/TextSpan.hpp b/src/TextSpan.hpp index 975de02..3621b46 100644 --- a/src/TextSpan.hpp +++ b/src/TextSpan.hpp @@ -1,8 +1,8 @@ -#ifndef ELOHIMSCRIPT_TEXTSPAN_HPP -#define ELOHIMSCRIPT_TEXTSPAN_HPP +#ifndef MALACHSCRIPT_TEXTSPAN_HPP +#define MALACHSCRIPT_TEXTSPAN_HPP #include -namespace ElohimScript { +namespace MalachScript { class TextSpan { size_t _start; size_t _end; @@ -16,4 +16,4 @@ namespace ElohimScript { }; } -#endif // ELOHIMSCRIPT_TEXTSPAN_HPP +#endif // MALACHSCRIPT_TEXTSPAN_HPP diff --git a/src/Utils/MemoryAllocator.hpp b/src/Utils/MemoryAllocator.hpp index a4d79e1..856f55b 100644 --- a/src/Utils/MemoryAllocator.hpp +++ b/src/Utils/MemoryAllocator.hpp @@ -1,11 +1,11 @@ -#ifndef ELOHIMSCRIPT_MEMORYALLOCATOR_HPP -#define ELOHIMSCRIPT_MEMORYALLOCATOR_HPP +#ifndef MALACHSCRIPT_MEMORYALLOCATOR_HPP +#define MALACHSCRIPT_MEMORYALLOCATOR_HPP #include #include #include -namespace ElohimScript::Utils { +namespace MalachScript::Utils { template class MemoryAllocator { size_t _offset; @@ -42,4 +42,4 @@ namespace ElohimScript::Utils { }; } -#endif // ELOHIMSCRIPT_MEMORYALLOCATOR_HPP +#endif // MALACHSCRIPT_MEMORYALLOCATOR_HPP diff --git a/tests/LexerTests/IdentifierLexTests.cpp b/tests/LexerTests/IdentifierLexTests.cpp index bf95b9e..e083d02 100644 --- a/tests/LexerTests/IdentifierLexTests.cpp +++ b/tests/LexerTests/IdentifierLexTests.cpp @@ -1,11 +1,11 @@ #include "../../extern/doctest.hpp" #include "../../src/Parser/Lexer/Lexer.hpp" -using namespace ElohimScript::Parser; +using namespace MalachScript::Parser; #define KEYWORD_TEST(script, symbol) \ TEST_CASE("Lex " script) { \ - ElohimScript::Diagnostics::Diagnostics diag; \ + MalachScript::Diagnostics::Diagnostics diag; \ auto lexer = Lexer(script, script, &diag); \ const auto* token = lexer.Lex(); \ CHECK(diag.GetMessages().empty()); \ @@ -92,7 +92,7 @@ namespace doctest { #define IDENTIFIER_TEST(identifier) \ TEST_CASE("Lex identifier " identifier) { \ - ElohimScript::Diagnostics::Diagnostics diag; \ + MalachScript::Diagnostics::Diagnostics diag; \ auto lexer = Lexer(identifier, identifier, &diag); \ const auto* token = lexer.Lex(); \ CHECK(diag.GetMessages().empty()); \ diff --git a/tests/LexerTests/LexerIntegrationTests.cpp b/tests/LexerTests/LexerIntegrationTests.cpp index edd5e22..347037f 100644 --- a/tests/LexerTests/LexerIntegrationTests.cpp +++ b/tests/LexerTests/LexerIntegrationTests.cpp @@ -1,11 +1,11 @@ #include "../../extern/doctest.hpp" #include "../../src/Parser/Lexer/Lexer.hpp" -using namespace ElohimScript::Parser; +using namespace MalachScript::Parser; #define LEX_TEST(script, ...) \ TEST_CASE("Lex: " script) { \ - ElohimScript::Diagnostics::Diagnostics diag; \ + MalachScript::Diagnostics::Diagnostics diag; \ auto lexer = Lexer(script, script, &diag); \ const auto* token = lexer.Lex(); \ CHECK(diag.GetMessages().empty()); \ diff --git a/tests/LexerTests/NumericalLexTests.cpp b/tests/LexerTests/NumericalLexTests.cpp index 26b99f0..ad6025e 100644 --- a/tests/LexerTests/NumericalLexTests.cpp +++ b/tests/LexerTests/NumericalLexTests.cpp @@ -1,11 +1,11 @@ #include "../../extern/doctest.hpp" #include "../../src/Parser/Lexer/Lexer.hpp" -using namespace ElohimScript::Parser; +using namespace MalachScript::Parser; #define INTEGER_TEST(script, expected) \ TEST_CASE("Lex " script) { \ - ElohimScript::Diagnostics::Diagnostics diag; \ + MalachScript::Diagnostics::Diagnostics diag; \ auto lexer = Lexer(script, script, &diag); \ const auto* token = lexer.Lex(); \ CHECK(diag.GetMessages().empty()); \ @@ -17,7 +17,7 @@ using namespace ElohimScript::Parser; #define FLOAT_TEST(script, expected) \ TEST_CASE("Lex " script) { \ - ElohimScript::Diagnostics::Diagnostics diag; \ + MalachScript::Diagnostics::Diagnostics diag; \ auto lexer = Lexer(script, script, &diag); \ const auto* token = lexer.Lex(); \ CHECK(diag.GetMessages().empty()); \ @@ -72,13 +72,13 @@ INTEGER_TEST("0B110011", 51); #undef FLOAT_TEST TEST_CASE("Lex invalid numerical base") { - ElohimScript::Diagnostics::Diagnostics diag; + MalachScript::Diagnostics::Diagnostics diag; auto lexer = Lexer("bad base", "0f553", &diag); 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)); + CHECK(messages[0].GetType() == MalachScript::Diagnostics::DiagnosticType::InvalidNumericalBase); + CHECK(messages[0].GetLevel() == MalachScript::Diagnostics::DiagnosticLevel::Error); + CHECK(messages[0].GetSpan() == MalachScript::TextSpan(0, 2)); CHECK(messages[0].GetScriptName() == u8"bad base"); } diff --git a/tests/LexerTests/StringLexTests.cpp b/tests/LexerTests/StringLexTests.cpp index 8318f87..15b0b94 100644 --- a/tests/LexerTests/StringLexTests.cpp +++ b/tests/LexerTests/StringLexTests.cpp @@ -1,11 +1,11 @@ #include "../../extern/doctest.hpp" #include "../../src/Parser/Lexer/Lexer.hpp" -using namespace ElohimScript::Parser; +using namespace MalachScript::Parser; #define STRING_TEST(str, constraint) \ TEST_CASE("Lex string " constraint str constraint) { \ - ElohimScript::Diagnostics::Diagnostics diag; \ + MalachScript::Diagnostics::Diagnostics diag; \ auto lexer = Lexer(str, constraint str constraint, &diag); \ const auto* token = lexer.Lex(); \ CHECK(diag.GetMessages().empty()); \ @@ -22,7 +22,7 @@ STRING_TEST("\"foo bar\"", "\"\"\""); STRING_TEST("\"\"foo bar\"\"", "\"\"\""); TEST_CASE("Lex multiline string") { - ElohimScript::Diagnostics::Diagnostics diag; + MalachScript::Diagnostics::Diagnostics diag; auto lexer = Lexer("multiline", R"("""foo bar""")", &diag); diff --git a/tests/LexerTests/SymbolLexTests.cpp b/tests/LexerTests/SymbolLexTests.cpp index 17c3897..38770a3 100644 --- a/tests/LexerTests/SymbolLexTests.cpp +++ b/tests/LexerTests/SymbolLexTests.cpp @@ -2,11 +2,11 @@ #include "../../extern/doctest.hpp" #include "../../src/Parser/Lexer/Lexer.hpp" -using namespace ElohimScript::Parser; +using namespace MalachScript::Parser; #define SYMBOL_TEST(script, symbol) \ TEST_CASE("Lex " script) { \ - ElohimScript::Diagnostics::Diagnostics diag; \ + MalachScript::Diagnostics::Diagnostics diag; \ auto lexer = Lexer(script, script, &diag); \ const auto* token = lexer.Lex(); \ CHECK(diag.GetMessages().empty()); \ @@ -73,7 +73,7 @@ SYMBOL_TEST(" ", Whitespace) TEST_CASE("Lex whitespace") { auto whitespace = {" ", "\t", "\n", "\r", "\xef\xbb\xbf"}; for (const auto* v : whitespace) { - ElohimScript::Diagnostics::Diagnostics diag; + MalachScript::Diagnostics::Diagnostics diag; auto lexer = Lexer("whitespace", v, &diag); const auto* token = lexer.Lex(); CHECK(diag.GetMessages().empty());