Renames project.
This commit is contained in:
parent
125bb8459c
commit
f299d5183f
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.17)
|
cmake_minimum_required(VERSION 3.17)
|
||||||
project(ElohimScript)
|
project(MalachScript)
|
||||||
|
|
||||||
# Enable all warnings, and make them error when occurring.
|
# Enable all warnings, and make them error when occurring.
|
||||||
add_compile_options(-Wall -Wextra -Werror)
|
add_compile_options(-Wall -Wextra -Werror)
|
||||||
|
@ -18,16 +18,16 @@ if (NOT WINDOWS)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp")
|
file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp")
|
||||||
add_library(ElohimScript SHARED ${SRC_FILES})
|
add_library(MalachScript SHARED ${SRC_FILES})
|
||||||
|
|
||||||
if (TESTS)
|
if (TESTS)
|
||||||
# Create Test executable
|
# Create Test executable
|
||||||
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
||||||
add_executable(ElohimScriptTests ${TEST_FILES} extern/doctest.hpp)
|
add_executable(MalachScriptTests ${TEST_FILES} extern/doctest.hpp)
|
||||||
target_link_libraries(ElohimScriptTests PUBLIC ElohimScript)
|
target_link_libraries(MalachScriptTests PUBLIC MalachScript)
|
||||||
|
|
||||||
# Add a definition for the test library
|
# Add a definition for the test library
|
||||||
target_compile_definitions(ElohimScriptTests PRIVATE TESTS_BUILD)
|
target_compile_definitions(MalachScriptTests PRIVATE TESTS_BUILD)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef ELOHIMSCRIPT_DIAGNOSTIC_HPP
|
#ifndef MALACHSCRIPT_DIAGNOSTIC_HPP
|
||||||
#define ELOHIMSCRIPT_DIAGNOSTIC_HPP
|
#define MALACHSCRIPT_DIAGNOSTIC_HPP
|
||||||
|
|
||||||
#include "../TextSpan.hpp"
|
#include "../TextSpan.hpp"
|
||||||
#include "DiagnosticLevel.hpp"
|
#include "DiagnosticLevel.hpp"
|
||||||
#include "DiagnosticType.hpp"
|
#include "DiagnosticType.hpp"
|
||||||
|
|
||||||
namespace ElohimScript::Diagnostics {
|
namespace MalachScript::Diagnostics {
|
||||||
class Diagnostic {
|
class Diagnostic {
|
||||||
DiagnosticLevel _level;
|
DiagnosticLevel _level;
|
||||||
DiagnosticType _type;
|
DiagnosticType _type;
|
||||||
|
@ -24,4 +24,4 @@ namespace ElohimScript::Diagnostics {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ELOHIMSCRIPT_DIAGNOSTIC_HPP
|
#endif // MALACHSCRIPT_DIAGNOSTIC_HPP
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef ELOHIMSCRIPT_DIAGNOSTICLEVEL_HPP
|
#ifndef MALACHSCRIPT_DIAGNOSTICLEVEL_HPP
|
||||||
#define ELOHIMSCRIPT_DIAGNOSTICLEVEL_HPP
|
#define MALACHSCRIPT_DIAGNOSTICLEVEL_HPP
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
namespace ElohimScript::Diagnostics {
|
namespace MalachScript::Diagnostics {
|
||||||
enum class DiagnosticLevel : uint8_t {
|
enum class DiagnosticLevel : uint8_t {
|
||||||
Trace,
|
Trace,
|
||||||
Information,
|
Information,
|
||||||
|
@ -12,4 +12,4 @@ namespace ElohimScript::Diagnostics {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ELOHIMSCRIPT_DIAGNOSTICLEVEL_HPP
|
#endif // MALACHSCRIPT_DIAGNOSTICLEVEL_HPP
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef ELOHIMSCRIPT_DIAGNOSTICTYPE_HPP
|
#ifndef MALACHSCRIPT_DIAGNOSTICTYPE_HPP
|
||||||
#define ELOHIMSCRIPT_DIAGNOSTICTYPE_HPP
|
#define MALACHSCRIPT_DIAGNOSTICTYPE_HPP
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace ElohimScript::Diagnostics {
|
namespace MalachScript::Diagnostics {
|
||||||
enum class DiagnosticType : uint8_t { UnknownToken, InvalidNumericalBase, ExpectedEndOfString };
|
enum class DiagnosticType : uint8_t { UnknownToken, InvalidNumericalBase, ExpectedEndOfString };
|
||||||
|
|
||||||
class DiagnosticTypeHelper {
|
class DiagnosticTypeHelper {
|
||||||
|
@ -17,4 +17,4 @@ namespace ElohimScript::Diagnostics {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ELOHIMSCRIPT_DIAGNOSTICTYPE_HPP
|
#endif // MALACHSCRIPT_DIAGNOSTICTYPE_HPP
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef ELOHIMSCRIPT_DIAGNOSTICS_HPP
|
#ifndef MALACHSCRIPT_DIAGNOSTICS_HPP
|
||||||
#define ELOHIMSCRIPT_DIAGNOSTICS_HPP
|
#define MALACHSCRIPT_DIAGNOSTICS_HPP
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "Diagnostic.hpp"
|
#include "Diagnostic.hpp"
|
||||||
|
|
||||||
namespace ElohimScript::Diagnostics {
|
namespace MalachScript::Diagnostics {
|
||||||
class Diagnostics {
|
class Diagnostics {
|
||||||
std::vector<Diagnostic> _messages;
|
std::vector<Diagnostic> _messages;
|
||||||
|
|
||||||
|
@ -32,4 +32,4 @@ namespace ElohimScript::Diagnostics {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ELOHIMSCRIPT_DIAGNOSTICS_HPP
|
#endif // MALACHSCRIPT_DIAGNOSTICS_HPP
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef MALACHSCRIPT_PARSEDEXPERSSION_HPP
|
||||||
|
#define MALACHSCRIPT_PARSEDEXPERSSION_HPP
|
||||||
|
|
||||||
|
namespace MalachScript::Parser{
|
||||||
|
class ParsedExpression{};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MALACHSCRIPT_PARSEDEXPERSSION_HPP
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef ELOHIMSCRIPT_LEXRESULT_HPP
|
#ifndef MALACHSCRIPT_LEXRESULT_HPP
|
||||||
#define ELOHIMSCRIPT_LEXRESULT_HPP
|
#define MALACHSCRIPT_LEXRESULT_HPP
|
||||||
|
|
||||||
#include "LexToken.hpp"
|
#include "LexToken.hpp"
|
||||||
namespace ElohimScript::Parser {
|
namespace MalachScript::Parser {
|
||||||
class LexResult {
|
class LexResult {
|
||||||
public:
|
public:
|
||||||
LexResult(const LexToken* first, const uint8_t* memoryMap) : _first(first), _memoryMap(memoryMap) {}
|
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
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef ELOHIMSCRIPT_LEXTOKEN_HPP
|
#ifndef MALACHSCRIPT_LEXTOKEN_HPP
|
||||||
#define ELOHIMSCRIPT_LEXTOKEN_HPP
|
#define MALACHSCRIPT_LEXTOKEN_HPP
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include "LexTokenKind.hpp"
|
#include "LexTokenKind.hpp"
|
||||||
|
|
||||||
namespace ElohimScript::Parser {
|
namespace MalachScript::Parser {
|
||||||
class LexToken {
|
class LexToken {
|
||||||
friend class Lexer;
|
friend class Lexer;
|
||||||
|
|
||||||
|
@ -62,4 +62,4 @@ namespace ElohimScript::Parser {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ELOHIMSCRIPT_LEXTOKEN_HPP
|
#endif // MALACHSCRIPT_LEXTOKEN_HPP
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef ELOHIMSCRIPT_LEXTOKENKIND_HPP
|
#ifndef MALACHSCRIPT_LEXTOKENKIND_HPP
|
||||||
#define ELOHIMSCRIPT_LEXTOKENKIND_HPP
|
#define MALACHSCRIPT_LEXTOKENKIND_HPP
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
namespace ElohimScript::Parser {
|
namespace MalachScript::Parser {
|
||||||
enum class LexTokenKind : uint8_t {
|
enum class LexTokenKind : uint8_t {
|
||||||
Unknown,
|
Unknown,
|
||||||
EndOfFile,
|
EndOfFile,
|
||||||
|
@ -136,4 +136,4 @@ namespace ElohimScript::Parser {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ELOHIMSCRIPT_LEXTOKENKIND_HPP
|
#endif // MALACHSCRIPT_LEXTOKENKIND_HPP
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "NumericalLexers.hpp"
|
#include "NumericalLexers.hpp"
|
||||||
|
|
||||||
namespace ElohimScript::Parser {
|
namespace MalachScript::Parser {
|
||||||
const LexToken* Lexer::Lex() {
|
const LexToken* Lexer::Lex() {
|
||||||
auto* first = LexNext();
|
auto* first = LexNext();
|
||||||
if (first->GetKind() == LexTokenKind::EndOfFile) {
|
if (first->GetKind() == LexTokenKind::EndOfFile) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#ifndef ELOHIMSCRIPT_LEXER_HPP
|
#ifndef MALACHSCRIPT_LEXER_HPP
|
||||||
#define ELOHIMSCRIPT_LEXER_HPP
|
#define MALACHSCRIPT_LEXER_HPP
|
||||||
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include "../../Diagnostics/Diagnostics.hpp"
|
#include "../../Diagnostics/Diagnostics.hpp"
|
||||||
#include "../../Utils/MemoryAllocator.hpp"
|
#include "../../Utils/MemoryAllocator.hpp"
|
||||||
#include "LexToken.hpp"
|
#include "LexToken.hpp"
|
||||||
|
|
||||||
namespace ElohimScript::Parser {
|
namespace MalachScript::Parser {
|
||||||
class Lexer {
|
class Lexer {
|
||||||
public:
|
public:
|
||||||
Lexer(const char* scriptName, const char* script, Diagnostics::Diagnostics* diag)
|
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
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef ELOHIMSCRIPT_NUMERICALLEXERS_HPP
|
#ifndef MALACHSCRIPT_NUMERICALLEXERS_HPP
|
||||||
#define ELOHIMSCRIPT_NUMERICALLEXERS_HPP
|
#define MALACHSCRIPT_NUMERICALLEXERS_HPP
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
@ -8,4 +8,4 @@ uint8_t LexHexadecimalValue(char8_t c);
|
||||||
uint8_t LexOctalValue(char8_t c);
|
uint8_t LexOctalValue(char8_t c);
|
||||||
uint8_t LexBinaryValue(char8_t c);
|
uint8_t LexBinaryValue(char8_t c);
|
||||||
|
|
||||||
#endif // ELOHIMSCRIPT_NUMERICALLEXERS_HPP
|
#endif // MALACHSCRIPT_NUMERICALLEXERS_HPP
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
#include "Parser.hpp"
|
||||||
|
|
||||||
|
namespace MalachScript::Parser {
|
||||||
|
ParsedScriptStatement* Parser::Parse() {
|
||||||
|
std::vector<const ParsedStatement*> 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
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
|
@ -0,0 +1,51 @@
|
||||||
|
#ifndef MALACHSCRIPT_PARSEDSTATEMENT_HPP
|
||||||
|
#define MALACHSCRIPT_PARSEDSTATEMENT_HPP
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#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 <ParsedStatementKind kind> class ParsedStatementImpl : public ParsedStatement {
|
||||||
|
public:
|
||||||
|
ParsedStatementImpl(TextSpan span) : ParsedStatement(span) {}
|
||||||
|
[[nodiscard]] inline ParsedStatementKind GetKind() const noexcept override { return kind; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class ParsedBlockStatement : public ParsedStatementImpl<ParsedStatementKind::Block> {
|
||||||
|
std::vector<std::unique_ptr<const ParsedStatement>> _statements;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ParsedBlockStatement(TextSpan span, const std::vector<const ParsedStatement*>& statements)
|
||||||
|
: ParsedStatementImpl<ParsedStatementKind::Block>(span), _statements(statements.size()) {
|
||||||
|
for (size_t i = 0; i < statements.size(); i++)
|
||||||
|
_statements[i] = std::unique_ptr<const ParsedStatement>(statements[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] inline const std::vector<std::unique_ptr<const ParsedStatement>>& GetStatements() const noexcept {
|
||||||
|
return _statements;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ParsedScriptStatement : public ParsedStatementImpl<ParsedStatementKind::Script> {
|
||||||
|
std::unique_ptr<const ParsedBlockStatement> _block;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ParsedScriptStatement(const ParsedBlockStatement* block)
|
||||||
|
: ParsedStatementImpl<ParsedStatementKind::Script>(block->GetSpan()), _block(block) {}
|
||||||
|
|
||||||
|
[[nodiscard]] inline const std::unique_ptr<const ParsedBlockStatement>& GetBlock() const noexcept {
|
||||||
|
return _block;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MALACHSCRIPT_PARSEDSTATEMENT_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
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef ELOHIMSCRIPT_TEXTSPAN_HPP
|
#ifndef MALACHSCRIPT_TEXTSPAN_HPP
|
||||||
#define ELOHIMSCRIPT_TEXTSPAN_HPP
|
#define MALACHSCRIPT_TEXTSPAN_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
namespace ElohimScript {
|
namespace MalachScript {
|
||||||
class TextSpan {
|
class TextSpan {
|
||||||
size_t _start;
|
size_t _start;
|
||||||
size_t _end;
|
size_t _end;
|
||||||
|
@ -16,4 +16,4 @@ namespace ElohimScript {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ELOHIMSCRIPT_TEXTSPAN_HPP
|
#endif // MALACHSCRIPT_TEXTSPAN_HPP
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef ELOHIMSCRIPT_MEMORYALLOCATOR_HPP
|
#ifndef MALACHSCRIPT_MEMORYALLOCATOR_HPP
|
||||||
#define ELOHIMSCRIPT_MEMORYALLOCATOR_HPP
|
#define MALACHSCRIPT_MEMORYALLOCATOR_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace ElohimScript::Utils {
|
namespace MalachScript::Utils {
|
||||||
template <size_t initialSize, size_t steps>
|
template <size_t initialSize, size_t steps>
|
||||||
class MemoryAllocator {
|
class MemoryAllocator {
|
||||||
size_t _offset;
|
size_t _offset;
|
||||||
|
@ -42,4 +42,4 @@ namespace ElohimScript::Utils {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ELOHIMSCRIPT_MEMORYALLOCATOR_HPP
|
#endif // MALACHSCRIPT_MEMORYALLOCATOR_HPP
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#include "../../extern/doctest.hpp"
|
#include "../../extern/doctest.hpp"
|
||||||
#include "../../src/Parser/Lexer/Lexer.hpp"
|
#include "../../src/Parser/Lexer/Lexer.hpp"
|
||||||
|
|
||||||
using namespace ElohimScript::Parser;
|
using namespace MalachScript::Parser;
|
||||||
|
|
||||||
#define KEYWORD_TEST(script, symbol) \
|
#define KEYWORD_TEST(script, symbol) \
|
||||||
TEST_CASE("Lex " script) { \
|
TEST_CASE("Lex " script) { \
|
||||||
ElohimScript::Diagnostics::Diagnostics diag; \
|
MalachScript::Diagnostics::Diagnostics diag; \
|
||||||
auto lexer = Lexer(script, script, &diag); \
|
auto lexer = Lexer(script, script, &diag); \
|
||||||
const auto* token = lexer.Lex(); \
|
const auto* token = lexer.Lex(); \
|
||||||
CHECK(diag.GetMessages().empty()); \
|
CHECK(diag.GetMessages().empty()); \
|
||||||
|
@ -92,7 +92,7 @@ namespace doctest {
|
||||||
|
|
||||||
#define IDENTIFIER_TEST(identifier) \
|
#define IDENTIFIER_TEST(identifier) \
|
||||||
TEST_CASE("Lex identifier " identifier) { \
|
TEST_CASE("Lex identifier " identifier) { \
|
||||||
ElohimScript::Diagnostics::Diagnostics diag; \
|
MalachScript::Diagnostics::Diagnostics diag; \
|
||||||
auto lexer = Lexer(identifier, identifier, &diag); \
|
auto lexer = Lexer(identifier, identifier, &diag); \
|
||||||
const auto* token = lexer.Lex(); \
|
const auto* token = lexer.Lex(); \
|
||||||
CHECK(diag.GetMessages().empty()); \
|
CHECK(diag.GetMessages().empty()); \
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#include "../../extern/doctest.hpp"
|
#include "../../extern/doctest.hpp"
|
||||||
#include "../../src/Parser/Lexer/Lexer.hpp"
|
#include "../../src/Parser/Lexer/Lexer.hpp"
|
||||||
|
|
||||||
using namespace ElohimScript::Parser;
|
using namespace MalachScript::Parser;
|
||||||
|
|
||||||
#define LEX_TEST(script, ...) \
|
#define LEX_TEST(script, ...) \
|
||||||
TEST_CASE("Lex: " script) { \
|
TEST_CASE("Lex: " script) { \
|
||||||
ElohimScript::Diagnostics::Diagnostics diag; \
|
MalachScript::Diagnostics::Diagnostics diag; \
|
||||||
auto lexer = Lexer(script, script, &diag); \
|
auto lexer = Lexer(script, script, &diag); \
|
||||||
const auto* token = lexer.Lex(); \
|
const auto* token = lexer.Lex(); \
|
||||||
CHECK(diag.GetMessages().empty()); \
|
CHECK(diag.GetMessages().empty()); \
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#include "../../extern/doctest.hpp"
|
#include "../../extern/doctest.hpp"
|
||||||
#include "../../src/Parser/Lexer/Lexer.hpp"
|
#include "../../src/Parser/Lexer/Lexer.hpp"
|
||||||
|
|
||||||
using namespace ElohimScript::Parser;
|
using namespace MalachScript::Parser;
|
||||||
|
|
||||||
#define INTEGER_TEST(script, expected) \
|
#define INTEGER_TEST(script, expected) \
|
||||||
TEST_CASE("Lex " script) { \
|
TEST_CASE("Lex " script) { \
|
||||||
ElohimScript::Diagnostics::Diagnostics diag; \
|
MalachScript::Diagnostics::Diagnostics diag; \
|
||||||
auto lexer = Lexer(script, script, &diag); \
|
auto lexer = Lexer(script, script, &diag); \
|
||||||
const auto* token = lexer.Lex(); \
|
const auto* token = lexer.Lex(); \
|
||||||
CHECK(diag.GetMessages().empty()); \
|
CHECK(diag.GetMessages().empty()); \
|
||||||
|
@ -17,7 +17,7 @@ using namespace ElohimScript::Parser;
|
||||||
|
|
||||||
#define FLOAT_TEST(script, expected) \
|
#define FLOAT_TEST(script, expected) \
|
||||||
TEST_CASE("Lex " script) { \
|
TEST_CASE("Lex " script) { \
|
||||||
ElohimScript::Diagnostics::Diagnostics diag; \
|
MalachScript::Diagnostics::Diagnostics diag; \
|
||||||
auto lexer = Lexer(script, script, &diag); \
|
auto lexer = Lexer(script, script, &diag); \
|
||||||
const auto* token = lexer.Lex(); \
|
const auto* token = lexer.Lex(); \
|
||||||
CHECK(diag.GetMessages().empty()); \
|
CHECK(diag.GetMessages().empty()); \
|
||||||
|
@ -72,13 +72,13 @@ INTEGER_TEST("0B110011", 51);
|
||||||
#undef FLOAT_TEST
|
#undef FLOAT_TEST
|
||||||
|
|
||||||
TEST_CASE("Lex invalid numerical base") {
|
TEST_CASE("Lex invalid numerical base") {
|
||||||
ElohimScript::Diagnostics::Diagnostics diag;
|
MalachScript::Diagnostics::Diagnostics diag;
|
||||||
auto lexer = Lexer("bad base", "0f553", &diag);
|
auto lexer = Lexer("bad base", "0f553", &diag);
|
||||||
lexer.Lex();
|
lexer.Lex();
|
||||||
const auto& messages = diag.GetMessages();
|
const auto& messages = diag.GetMessages();
|
||||||
REQUIRE(messages.size() == 1);
|
REQUIRE(messages.size() == 1);
|
||||||
CHECK(messages[0].GetType() == ElohimScript::Diagnostics::DiagnosticType::InvalidNumericalBase);
|
CHECK(messages[0].GetType() == MalachScript::Diagnostics::DiagnosticType::InvalidNumericalBase);
|
||||||
CHECK(messages[0].GetLevel() == ElohimScript::Diagnostics::DiagnosticLevel::Error);
|
CHECK(messages[0].GetLevel() == MalachScript::Diagnostics::DiagnosticLevel::Error);
|
||||||
CHECK(messages[0].GetSpan() == ElohimScript::TextSpan(0, 2));
|
CHECK(messages[0].GetSpan() == MalachScript::TextSpan(0, 2));
|
||||||
CHECK(messages[0].GetScriptName() == u8"bad base");
|
CHECK(messages[0].GetScriptName() == u8"bad base");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#include "../../extern/doctest.hpp"
|
#include "../../extern/doctest.hpp"
|
||||||
#include "../../src/Parser/Lexer/Lexer.hpp"
|
#include "../../src/Parser/Lexer/Lexer.hpp"
|
||||||
|
|
||||||
using namespace ElohimScript::Parser;
|
using namespace MalachScript::Parser;
|
||||||
|
|
||||||
#define STRING_TEST(str, constraint) \
|
#define STRING_TEST(str, constraint) \
|
||||||
TEST_CASE("Lex string " constraint 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); \
|
auto lexer = Lexer(str, constraint str constraint, &diag); \
|
||||||
const auto* token = lexer.Lex(); \
|
const auto* token = lexer.Lex(); \
|
||||||
CHECK(diag.GetMessages().empty()); \
|
CHECK(diag.GetMessages().empty()); \
|
||||||
|
@ -22,7 +22,7 @@ STRING_TEST("\"foo bar\"", "\"\"\"");
|
||||||
STRING_TEST("\"\"foo bar\"\"", "\"\"\"");
|
STRING_TEST("\"\"foo bar\"\"", "\"\"\"");
|
||||||
|
|
||||||
TEST_CASE("Lex multiline string") {
|
TEST_CASE("Lex multiline string") {
|
||||||
ElohimScript::Diagnostics::Diagnostics diag;
|
MalachScript::Diagnostics::Diagnostics diag;
|
||||||
auto lexer = Lexer("multiline", R"("""foo
|
auto lexer = Lexer("multiline", R"("""foo
|
||||||
bar""")",
|
bar""")",
|
||||||
&diag);
|
&diag);
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
#include "../../extern/doctest.hpp"
|
#include "../../extern/doctest.hpp"
|
||||||
#include "../../src/Parser/Lexer/Lexer.hpp"
|
#include "../../src/Parser/Lexer/Lexer.hpp"
|
||||||
|
|
||||||
using namespace ElohimScript::Parser;
|
using namespace MalachScript::Parser;
|
||||||
|
|
||||||
#define SYMBOL_TEST(script, symbol) \
|
#define SYMBOL_TEST(script, symbol) \
|
||||||
TEST_CASE("Lex " script) { \
|
TEST_CASE("Lex " script) { \
|
||||||
ElohimScript::Diagnostics::Diagnostics diag; \
|
MalachScript::Diagnostics::Diagnostics diag; \
|
||||||
auto lexer = Lexer(script, script, &diag); \
|
auto lexer = Lexer(script, script, &diag); \
|
||||||
const auto* token = lexer.Lex(); \
|
const auto* token = lexer.Lex(); \
|
||||||
CHECK(diag.GetMessages().empty()); \
|
CHECK(diag.GetMessages().empty()); \
|
||||||
|
@ -73,7 +73,7 @@ SYMBOL_TEST(" ", Whitespace)
|
||||||
TEST_CASE("Lex whitespace") {
|
TEST_CASE("Lex whitespace") {
|
||||||
auto whitespace = {" ", "\t", "\n", "\r", "\xef\xbb\xbf"};
|
auto whitespace = {" ", "\t", "\n", "\r", "\xef\xbb\xbf"};
|
||||||
for (const auto* v : whitespace) {
|
for (const auto* v : whitespace) {
|
||||||
ElohimScript::Diagnostics::Diagnostics diag;
|
MalachScript::Diagnostics::Diagnostics diag;
|
||||||
auto lexer = Lexer("whitespace", v, &diag);
|
auto lexer = Lexer("whitespace", v, &diag);
|
||||||
const auto* token = lexer.Lex();
|
const auto* token = lexer.Lex();
|
||||||
CHECK(diag.GetMessages().empty());
|
CHECK(diag.GetMessages().empty());
|
||||||
|
|
Loading…
Reference in New Issue