Initial work on type registration in the binder.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-01-08 16:14:02 +01:00
parent da82819fff
commit 093ffde6bc
36 changed files with 819 additions and 386 deletions

View File

@@ -13,7 +13,7 @@ using namespace MalachScript;
vec[i]->SetNext(vec[i + 1]); \
} \
Diagnostics::Logger diags; \
auto* script = Parser::Parser::Parse(vec.front(), u8"scriptname", &diags); \
auto* script = Parser::Parser::Parse(vec.front(), "scriptname", &diags); \
REQUIRE(diags.GetMessages().empty()); \
asserts; \
delete vec[0]; \
@@ -24,7 +24,7 @@ using namespace MalachScript;
PARSER_TEST("Parse basic class without body",
PARSER_TEST_TOKENS(new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foobar"),
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0))),
{
REQUIRE(script->GetStatements().size() == 1);
@@ -34,7 +34,7 @@ PARSER_TEST("Parse basic class without body",
PARSER_TEST("Parse basic class without body with whitespaces",
PARSER_TEST_TOKENS(new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::Whitespace>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foobar"),
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::Whitespace>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0))),
{
@@ -45,7 +45,7 @@ PARSER_TEST("Parse basic class without body with whitespaces",
PARSER_TEST(
"Parse basic class with empty body",
PARSER_TEST_TOKENS(new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foobar"),
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0))),
{

View File

@@ -13,7 +13,7 @@ using namespace MalachScript;
vec[i]->SetNext(vec[i + 1]); \
} \
Diagnostics::Logger diags; \
auto* script = Parser::Parser::Parse(vec.front(), u8"scriptname", &diags); \
auto* script = Parser::Parser::Parse(vec.front(), "scriptname", &diags); \
REQUIRE(diags.GetMessages().empty()); \
asserts; \
delete vec[0]; \
@@ -25,7 +25,7 @@ using namespace MalachScript;
PARSER_TEST("Parse ``void foobar();``",
PARSER_TEST_TOKENS(new Parser::LexTokenImpl<Parser::LexTokenKind::VoidKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::Whitespace>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foobar"),
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0))),
@@ -41,9 +41,9 @@ PARSER_TEST("Parse ``void foobar();``",
CHECK_FALSE(type->IsArray());
CHECK_FALSE(type->IsHandle());
auto& id = type->GetScopedIdentifier();
CHECK(id.GetIdentifier().GetString() == u8"void");
CHECK(id.GetIdentifier().GetString() == "void");
CHECK_FALSE(funcStat->ReturnsReference());
CHECK(funcStat->GetIdentifier().GetString() == u8"foobar");
CHECK(funcStat->GetIdentifier().GetString() == "foobar");
auto paramList = (const MalachScript::Parser::ParsedParamListStatement*)funcStat->GetParamList().get();
CHECK(paramList->GetParameters().empty());
CHECK_FALSE(funcStat->IsConst());
@@ -52,13 +52,13 @@ PARSER_TEST("Parse ``void foobar();``",
})
PARSER_TEST("Parse scoped function without body.",
PARSER_TEST_TOKENS(new Parser::IdentifierToken(TextSpan(0, 0), u8"foo"),
PARSER_TEST_TOKENS(new Parser::IdentifierToken(TextSpan(0, 0), "foo"),
new Parser::LexTokenImpl<Parser::LexTokenKind::ColonColonSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"bar"),
new Parser::IdentifierToken(TextSpan(0, 0), "bar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::ColonColonSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"baz"),
new Parser::IdentifierToken(TextSpan(0, 0), "baz"),
new Parser::LexTokenImpl<Parser::LexTokenKind::Whitespace>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foobar"),
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0))),
@@ -74,11 +74,11 @@ PARSER_TEST("Parse scoped function without body.",
CHECK_FALSE(type->IsArray());
CHECK_FALSE(type->IsHandle());
auto& id = type->GetScopedIdentifier();
CHECK(id.GetIdentifier().GetString() == u8"baz");
CHECK(id.GetScope()[1].GetString() == u8"bar");
CHECK(id.GetScope()[0].GetString() == u8"foo");
CHECK(id.GetIdentifier().GetString() == "baz");
CHECK(id.GetScope()[1].GetString() == "bar");
CHECK(id.GetScope()[0].GetString() == "foo");
CHECK_FALSE(funcStat->ReturnsReference());
CHECK(funcStat->GetIdentifier().GetString() == u8"foobar");
CHECK(funcStat->GetIdentifier().GetString() == "foobar");
auto paramList = (const MalachScript::Parser::ParsedParamListStatement*)funcStat->GetParamList().get();
CHECK(paramList->GetParameters().empty());
CHECK_FALSE(funcStat->IsConst());
@@ -87,24 +87,24 @@ PARSER_TEST("Parse scoped function without body.",
})
PARSER_TEST("Parse scoped function with parameters without body.",
PARSER_TEST_TOKENS(new Parser::IdentifierToken(TextSpan(0, 0), u8"foo"),
PARSER_TEST_TOKENS(new Parser::IdentifierToken(TextSpan(0, 0), "foo"),
new Parser::LexTokenImpl<Parser::LexTokenKind::ColonColonSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"bar"),
new Parser::IdentifierToken(TextSpan(0, 0), "bar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::ColonColonSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"baz"),
new Parser::IdentifierToken(TextSpan(0, 0), "baz"),
new Parser::LexTokenImpl<Parser::LexTokenKind::Whitespace>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foobar"),
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::IntKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::Whitespace>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"par1"),
new Parser::IdentifierToken(TextSpan(0, 0), "par1"),
new Parser::LexTokenImpl<Parser::LexTokenKind::CommaSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::BoolKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::Whitespace>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"par2"),
new Parser::IdentifierToken(TextSpan(0, 0), "par2"),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0))),
@@ -120,11 +120,11 @@ PARSER_TEST("Parse scoped function with parameters without body.",
CHECK_FALSE(type->IsArray());
CHECK_FALSE(type->IsHandle());
auto& id = type->GetScopedIdentifier();
CHECK(id.GetIdentifier().GetString() == u8"baz");
CHECK(id.GetScope()[1].GetString() == u8"bar");
CHECK(id.GetScope()[0].GetString() == u8"foo");
CHECK(id.GetIdentifier().GetString() == "baz");
CHECK(id.GetScope()[1].GetString() == "bar");
CHECK(id.GetScope()[0].GetString() == "foo");
CHECK_FALSE(funcStat->ReturnsReference());
CHECK(funcStat->GetIdentifier().GetString() == u8"foobar");
CHECK(funcStat->GetIdentifier().GetString() == "foobar");
auto paramList = (const MalachScript::Parser::ParsedParamListStatement*)funcStat->GetParamList().get();
CHECK(paramList->GetParameters().size() == 2);
@@ -133,9 +133,9 @@ PARSER_TEST("Parse scoped function with parameters without body.",
CHECK_FALSE(par1.GetTypeStatement()->IsArray());
CHECK_FALSE(par1.GetTypeStatement()->IsHandle());
auto& par1TypeId = par1.GetTypeStatement()->GetScopedIdentifier();
CHECK(par1TypeId.GetIdentifier().GetString() == u8"int");
CHECK(par1TypeId.GetIdentifier().GetString() == "int");
CHECK(par1.GetTypeMod() == TypeMod::None);
CHECK(par1.GetIdentifier().GetString() == u8"par1");
CHECK(par1.GetIdentifier().GetString() == "par1");
CHECK(par1.GetDefaultExpression() == nullptr);
auto& par2 = *paramList->GetParameters()[1];
@@ -143,9 +143,9 @@ PARSER_TEST("Parse scoped function with parameters without body.",
CHECK_FALSE(par2.GetTypeStatement()->IsArray());
CHECK_FALSE(par2.GetTypeStatement()->IsHandle());
auto& par2TypeId = par2.GetTypeStatement()->GetScopedIdentifier();
CHECK(par2TypeId.GetIdentifier().GetString() == u8"bool");
CHECK(par2TypeId.GetIdentifier().GetString() == "bool");
CHECK(par2.GetTypeMod() == TypeMod::None);
CHECK(par2.GetIdentifier().GetString() == u8"par2");
CHECK(par2.GetIdentifier().GetString() == "par2");
CHECK(par2.GetDefaultExpression() == nullptr);
CHECK_FALSE(funcStat->IsConst());
@@ -154,20 +154,20 @@ PARSER_TEST("Parse scoped function with parameters without body.",
})
PARSER_TEST("Parse scoped function with reference parameters without body.",
PARSER_TEST_TOKENS(new Parser::IdentifierToken(TextSpan(0, 0), u8"foo"),
PARSER_TEST_TOKENS(new Parser::IdentifierToken(TextSpan(0, 0), "foo"),
new Parser::LexTokenImpl<Parser::LexTokenKind::ColonColonSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"bar"),
new Parser::IdentifierToken(TextSpan(0, 0), "bar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::ColonColonSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"baz"),
new Parser::IdentifierToken(TextSpan(0, 0), "baz"),
new Parser::LexTokenImpl<Parser::LexTokenKind::Whitespace>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foobar"),
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::IntKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::AmpersandSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::InKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::Whitespace>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"par1"),
new Parser::IdentifierToken(TextSpan(0, 0), "par1"),
new Parser::LexTokenImpl<Parser::LexTokenKind::CommaSymbol>(TextSpan(0, 0)),
@@ -175,7 +175,7 @@ PARSER_TEST("Parse scoped function with reference parameters without body.",
new Parser::LexTokenImpl<Parser::LexTokenKind::AmpersandSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::OutKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::Whitespace>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"par2"),
new Parser::IdentifierToken(TextSpan(0, 0), "par2"),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0))),
@@ -191,11 +191,11 @@ PARSER_TEST("Parse scoped function with reference parameters without body.",
CHECK_FALSE(type->IsArray());
CHECK_FALSE(type->IsHandle());
auto& id = type->GetScopedIdentifier();
CHECK(id.GetIdentifier().GetString() == u8"baz");
CHECK(id.GetScope()[1].GetString() == u8"bar");
CHECK(id.GetScope()[0].GetString() == u8"foo");
CHECK(id.GetIdentifier().GetString() == "baz");
CHECK(id.GetScope()[1].GetString() == "bar");
CHECK(id.GetScope()[0].GetString() == "foo");
CHECK_FALSE(funcStat->ReturnsReference());
CHECK(funcStat->GetIdentifier().GetString() == u8"foobar");
CHECK(funcStat->GetIdentifier().GetString() == "foobar");
auto paramList = (const MalachScript::Parser::ParsedParamListStatement*)funcStat->GetParamList().get();
CHECK(paramList->GetParameters().size() == 2);
@@ -204,9 +204,9 @@ PARSER_TEST("Parse scoped function with reference parameters without body.",
CHECK_FALSE(par1.GetTypeStatement()->IsArray());
CHECK_FALSE(par1.GetTypeStatement()->IsHandle());
auto& par1TypeId = par1.GetTypeStatement()->GetScopedIdentifier();
CHECK(par1TypeId.GetIdentifier().GetString() == u8"int");
CHECK(par1TypeId.GetIdentifier().GetString() == "int");
CHECK(par1.GetTypeMod() == TypeMod::RefIn);
CHECK(par1.GetIdentifier().GetString() == u8"par1");
CHECK(par1.GetIdentifier().GetString() == "par1");
CHECK(par1.GetDefaultExpression() == nullptr);
auto& par2 = *paramList->GetParameters()[1];
@@ -214,9 +214,9 @@ PARSER_TEST("Parse scoped function with reference parameters without body.",
CHECK_FALSE(par2.GetTypeStatement()->IsArray());
CHECK_FALSE(par2.GetTypeStatement()->IsHandle());
auto& par2TypeId = par2.GetTypeStatement()->GetScopedIdentifier();
CHECK(par2TypeId.GetIdentifier().GetString() == u8"bool");
CHECK(par2TypeId.GetIdentifier().GetString() == "bool");
CHECK(par2.GetTypeMod() == TypeMod::RefOut);
CHECK(par2.GetIdentifier().GetString() == u8"par2");
CHECK(par2.GetIdentifier().GetString() == "par2");
CHECK(par2.GetDefaultExpression() == nullptr);
CHECK_FALSE(funcStat->IsConst());

View File

@@ -7,9 +7,9 @@ using namespace MalachScript;
#define PARSE_TEST(name, scriptText, asserts) \
TEST_CASE(name) { \
Diagnostics::Logger diags; \
auto lexer = Parser::Lexer(u8##name, u8##scriptText, &diags); \
auto lexer = Parser::Lexer(name, scriptText, &diags); \
auto token = lexer.Lex(); \
auto script = Parser::Parser::Parse(token, u8##name, &diags); \
auto script = Parser::Parser::Parse(token, name, &diags); \
asserts; \
delete script; \
}
@@ -42,7 +42,7 @@ PARSE_TEST("Parse class with virtprop", "class foobar { private bool foo { get;
REQUIRE(firstClassStatement->GetKind() == Parser::ParsedStatementKind::VirtProp);
auto virtPropStatement = dynamic_cast<const MalachScript::Parser::ParsedVirtPropStatement*>(firstClassStatement);
REQUIRE(virtPropStatement->GetAccess() == MalachScript::AccessModifier::Private);
REQUIRE(virtPropStatement->GetIdentifier().GetString() == u8"foo");
REQUIRE(virtPropStatement->GetIdentifier().GetString() == "foo");
REQUIRE(virtPropStatement->HasGet());
REQUIRE(virtPropStatement->HasSet());
REQUIRE(virtPropStatement->GetGetStatement() == nullptr);

View File

@@ -13,7 +13,7 @@ using namespace MalachScript;
vec[i]->SetNext(vec[i + 1]); \
} \
Diagnostics::Logger diags; \
auto* script = Parser::Parser::Parse(vec.front(), u8"scriptname", &diags); \
auto* script = Parser::Parser::Parse(vec.front(), "scriptname", &diags); \
REQUIRE(diags.GetMessages().empty()); \
asserts; \
delete vec[0]; \
@@ -25,10 +25,10 @@ using namespace MalachScript;
PARSER_TEST(
"Parse class foobar { bool foo { get; set; } }",
PARSER_TEST_TOKENS(new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foobar"),
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"bool"),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foo"),
new Parser::IdentifierToken(TextSpan(0, 0), "bool"),
new Parser::IdentifierToken(TextSpan(0, 0), "foo"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::GetKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
@@ -46,7 +46,7 @@ PARSER_TEST(
auto virtPropStatement =
dynamic_cast<const MalachScript::Parser::ParsedVirtPropStatement*>(firstClassStatement);
REQUIRE(virtPropStatement->GetAccess() == MalachScript::AccessModifier::Public);
REQUIRE(virtPropStatement->GetIdentifier().GetString() == u8"foo");
REQUIRE(virtPropStatement->GetIdentifier().GetString() == "foo");
REQUIRE(virtPropStatement->HasGet());
REQUIRE(virtPropStatement->HasSet());
REQUIRE_FALSE(virtPropStatement->IsGetConst());
@@ -58,10 +58,10 @@ PARSER_TEST(
PARSER_TEST(
"Parse class foobar { bool foo { get const; set const; } }",
PARSER_TEST_TOKENS(new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foobar"),
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"bool"),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foo"),
new Parser::IdentifierToken(TextSpan(0, 0), "bool"),
new Parser::IdentifierToken(TextSpan(0, 0), "foo"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::GetKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::ConstKeyword>(TextSpan(0, 0)),
@@ -81,7 +81,7 @@ PARSER_TEST(
auto virtPropStatement =
dynamic_cast<const MalachScript::Parser::ParsedVirtPropStatement*>(firstClassStatement);
REQUIRE(virtPropStatement->GetAccess() == MalachScript::AccessModifier::Public);
REQUIRE(virtPropStatement->GetIdentifier().GetString() == u8"foo");
REQUIRE(virtPropStatement->GetIdentifier().GetString() == "foo");
REQUIRE(virtPropStatement->HasGet());
REQUIRE(virtPropStatement->HasSet());
REQUIRE(virtPropStatement->IsGetConst());
@@ -93,10 +93,10 @@ PARSER_TEST(
PARSER_TEST(
"Parse class foobar { bool foo { get const override; set const override; } }",
PARSER_TEST_TOKENS(new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foobar"),
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"bool"),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foo"),
new Parser::IdentifierToken(TextSpan(0, 0), "bool"),
new Parser::IdentifierToken(TextSpan(0, 0), "foo"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::GetKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::ConstKeyword>(TextSpan(0, 0)),
@@ -118,7 +118,7 @@ PARSER_TEST(
auto virtPropStatement =
dynamic_cast<const MalachScript::Parser::ParsedVirtPropStatement*>(firstClassStatement);
REQUIRE(virtPropStatement->GetAccess() == MalachScript::AccessModifier::Public);
REQUIRE(virtPropStatement->GetIdentifier().GetString() == u8"foo");
REQUIRE(virtPropStatement->GetIdentifier().GetString() == "foo");
REQUIRE(virtPropStatement->HasGet());
REQUIRE(virtPropStatement->HasSet());
REQUIRE(virtPropStatement->IsGetConst());
@@ -145,48 +145,47 @@ PARSER_TEST(
PARSER_TEST(
"Virtprops with bodies",
PARSER_TEST_TOKENS(new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foobar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"int"),
new Parser::IdentifierToken(TextSpan(0, 0), u8"i"),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
PARSER_TEST_TOKENS(
new Parser::LexTokenImpl<Parser::LexTokenKind::ClassKeyword>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), "foobar"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), "int"), new Parser::IdentifierToken(TextSpan(0, 0), "i"),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"bool"),
new Parser::IdentifierToken(TextSpan(0, 0), u8"foo"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::GetKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::IfKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::TrueKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::ReturnKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::TrueKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::ReturnKeyword>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), "bool"), new Parser::IdentifierToken(TextSpan(0, 0), "foo"),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::GetKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::IfKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::TrueKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::ReturnKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::TrueKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::ReturnKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::FalseKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SetKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::IfKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenParenthesisSymbol>(TextSpan(0, 0)),
new Parser::IntegerLiteral(TextSpan(0, 0), 1),
new Parser::LexTokenImpl<Parser::LexTokenKind::EqualsEqualsSymbol>(TextSpan(0, 0)),
new Parser::IntegerLiteral(TextSpan(0, 0), 1),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseParenthesisSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"i"),
new Parser::LexTokenImpl<Parser::LexTokenKind::PlusPlusSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), u8"i"),
new Parser::LexTokenImpl<Parser::LexTokenKind::MinusMinusSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SetKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::IfKeyword>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::OpenParenthesisSymbol>(TextSpan(0, 0)),
new Parser::IntegerLiteral(TextSpan(0, 0), 1),
new Parser::LexTokenImpl<Parser::LexTokenKind::EqualsEqualsSymbol>(TextSpan(0, 0)),
new Parser::IntegerLiteral(TextSpan(0, 0), 1),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseParenthesisSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), "i"),
new Parser::LexTokenImpl<Parser::LexTokenKind::PlusPlusSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
new Parser::IdentifierToken(TextSpan(0, 0), "i"),
new Parser::LexTokenImpl<Parser::LexTokenKind::MinusMinusSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::SemicolonSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0))),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0)),
new Parser::LexTokenImpl<Parser::LexTokenKind::CloseCurlyParenthesisSymbol>(TextSpan(0, 0))),
{
REQUIRE(script->GetStatements().size() == 1);
auto firstStatement = script->GetStatements()[0].get();
@@ -197,7 +196,7 @@ PARSER_TEST(
auto virtPropStatement =
dynamic_cast<const MalachScript::Parser::ParsedVirtPropStatement*>(firstClassStatement);
REQUIRE(virtPropStatement->GetAccess() == MalachScript::AccessModifier::Public);
REQUIRE(virtPropStatement->GetIdentifier().GetString() == u8"foo");
REQUIRE(virtPropStatement->GetIdentifier().GetString() == "foo");
REQUIRE(virtPropStatement->HasGet());
REQUIRE(virtPropStatement->HasSet());
REQUIRE_FALSE(virtPropStatement->IsGetConst());