1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Changed isSimpleEnum classification to be more permissive

This commit is contained in:
Brian Fiete 2020-03-22 07:12:57 -07:00
parent 5d4d21cce1
commit 32c09bf94b

View file

@ -7560,18 +7560,62 @@ BfAstNode* BfReducer::CreateTopLevelObject(BfTokenNode* tokenNode, BfAttributeDi
SetAndRestoreValue<BfVisitorPos> prevVisitorPos(mVisitorPos, BfVisitorPos(block));
mVisitorPos.MoveNext();
BfAstNode* headNode = block->mChildArr.GetAs<BfAstNode*>(0);
if (auto nameNode = BfNodeDynCast<BfIdentifierNode>(headNode))
bool hadIllegal = false;
bool inAssignment = false;
int checkIdx = 0;
while (true)
{
auto nextNode = mVisitorPos.Get(1);
if (auto nextToken = BfNodeDynCast<BfTokenNode>(nextNode))
auto node = block->mChildArr.Get(checkIdx);
if (node == NULL)
break;
if (auto identifierNode = BfNodeDynCast<BfIdentifierNode>(node))
{
// Allow
}
else if (auto tokenNode = BfNodeDynCast<BfTokenNode>(node))
{
if (tokenNode->mToken == BfToken_Comma)
{
// Allow
inAssignment = false;
}
else if (tokenNode->mToken == BfToken_AssignEquals)
{
inAssignment = true;
}
else if (tokenNode->mToken == BfToken_Semicolon)
{
hadIllegal = true;
break;
}
else
{
if (!inAssignment)
{
hadIllegal = true;
break;
}
}
}
else
{
if (!inAssignment)
{
hadIllegal = true;
break;
}
}
checkIdx++;
}
if (!hadIllegal)
{
if ((nextToken->GetToken() == BfToken_Comma) || (nextToken->GetToken() == BfToken_AssignEquals))
isSimpleEnum = true;
}
if (nextNode == NULL)
isSimpleEnum = true;
}
break;
}