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

pragma format disable/restore, better space handing in formatting

This commit is contained in:
Brian Fiete 2022-05-24 06:20:35 -07:00
parent f9396f69c0
commit dd6e7f0c2a
4 changed files with 128 additions and 46 deletions

View file

@ -785,7 +785,7 @@ void BfParser::HandlePragma(const StringImpl& pragma, BfBlock* block)
auto itr = block->begin();
auto paramNode = *itr;
if (paramNode->ToString() == "warning")
if (paramNode->ToStringView() == "warning")
{
++itr;
//auto iterNode = paramNode->mNext;
@ -797,11 +797,11 @@ void BfParser::HandlePragma(const StringImpl& pragma, BfBlock* block)
++itr;
bool enable;
if (iterNode->ToString() == "disable")
if (iterNode->ToStringView() == "disable")
{
enable = false;
}
else if (iterNode->ToString() == "restore")
else if (iterNode->ToStringView() == "restore")
{
enable = true;
}
@ -851,6 +851,19 @@ void BfParser::HandlePragma(const StringImpl& pragma, BfBlock* block)
mPassInstance->FailAfterAt("Expected \"disable\" or \"restore\" after \"warning\"", mSourceData, paramNode->GetSrcEnd() - 1);
}
}
else if (paramNode->ToStringView() == "format")
{
++itr;
BfAstNode* iterNode = itr.Get();
if (iterNode)
{
if ((iterNode->ToStringView() != "disable") &&
(iterNode->ToStringView() != "restore"))
{
mPassInstance->FailAfterAt("Expected \"disable\" or \"restore\" after \"format\"", mSourceData, paramNode->GetSrcEnd() - 1);
}
}
}
else
{
mPassInstance->FailAt("Unknown #pragma directive", mSourceData, paramNode->GetSrcStart(), paramNode->GetSrcLength());
@ -2306,7 +2319,7 @@ void BfParser::NextToken(int endIdx, bool outerIsInterpolate, bool disablePrepro
}
}
if (!handled)
if ((!handled) && (!disablePreprocessor))
{
auto bfCommentNode = mAlloc->Alloc<BfCommentNode>();
bfCommentNode->Init(this);