|
@@ -50,6 +50,7 @@ BfReducer::BfReducer()
|
|
mDocumentCheckIdx = 0;
|
|
mDocumentCheckIdx = 0;
|
|
mTypeMemberNodeStart = NULL;
|
|
mTypeMemberNodeStart = NULL;
|
|
mCurTypeState = NULL;
|
|
mCurTypeState = NULL;
|
|
|
|
+ mLastErrorSrcEnd = -1;
|
|
}
|
|
}
|
|
|
|
|
|
bool BfReducer::IsSemicolon(BfAstNode* node)
|
|
bool BfReducer::IsSemicolon(BfAstNode* node)
|
|
@@ -84,7 +85,7 @@ void BfReducer::AssertCurrentNode(BfAstNode* node)
|
|
auto currentNode = mVisitorPos.GetCurrent();
|
|
auto currentNode = mVisitorPos.GetCurrent();
|
|
if (currentNode == NULL)
|
|
if (currentNode == NULL)
|
|
return;
|
|
return;
|
|
- if (!node->LocationEndEquals(currentNode))
|
|
|
|
|
|
+ if ((!node->LocationEndEquals(currentNode)) && (mLastErrorSrcEnd != currentNode->mSrcEnd))
|
|
{
|
|
{
|
|
const char* lastCPtr = &node->GetSourceData()->mSrc[node->GetSrcEnd() - 1];
|
|
const char* lastCPtr = &node->GetSourceData()->mSrc[node->GetSrcEnd() - 1];
|
|
// We have an "exceptional" case where breaking a double chevron will look like a position error
|
|
// We have an "exceptional" case where breaking a double chevron will look like a position error
|
|
@@ -237,6 +238,7 @@ void BfReducer::AddErrorNode(BfAstNode* astNode, bool removeNode)
|
|
mSource->AddErrorNode(astNode);
|
|
mSource->AddErrorNode(astNode);
|
|
if (removeNode)
|
|
if (removeNode)
|
|
astNode->RemoveSelf();
|
|
astNode->RemoveSelf();
|
|
|
|
+ mLastErrorSrcEnd = astNode->mSrcEnd;
|
|
}
|
|
}
|
|
|
|
|
|
bool BfReducer::IsTypeReference(BfAstNode* checkNode, BfToken successToken, int endNode, int* retryNode, int* outEndNode, bool* couldBeExpr, bool* isGenericType, bool* isTuple)
|
|
bool BfReducer::IsTypeReference(BfAstNode* checkNode, BfToken successToken, int endNode, int* retryNode, int* outEndNode, bool* couldBeExpr, bool* isGenericType, bool* isTuple)
|
|
@@ -5739,7 +5741,14 @@ BfTypeReference* BfReducer::CreateTypeRefAfter(BfAstNode* astNode, CreateTypeRef
|
|
BfTypeReference* typeRef = CreateTypeRef(nextNode, createTypeRefFlags);
|
|
BfTypeReference* typeRef = CreateTypeRef(nextNode, createTypeRefFlags);
|
|
if (typeRef == NULL)
|
|
if (typeRef == NULL)
|
|
{
|
|
{
|
|
- BF_ASSERT(mVisitorPos.mReadPos == startPos);
|
|
|
|
|
|
+ if (mLastErrorSrcEnd > startPos)
|
|
|
|
+ {
|
|
|
|
+ // We added an error node and made progress
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ BF_ASSERT(mVisitorPos.mReadPos == startPos);
|
|
|
|
+ }
|
|
mVisitorPos.mReadPos--;
|
|
mVisitorPos.mReadPos--;
|
|
}
|
|
}
|
|
return typeRef;
|
|
return typeRef;
|
|
@@ -8264,13 +8273,18 @@ void BfReducer::InitAnonymousType(BfTypeDeclaration* typeDecl)
|
|
typeDecl->mAnonymousName = (char*)mAlloc->AllocBytes(len);
|
|
typeDecl->mAnonymousName = (char*)mAlloc->AllocBytes(len);
|
|
memcpy(typeDecl->mAnonymousName, name.c_str(), len);
|
|
memcpy(typeDecl->mAnonymousName, name.c_str(), len);
|
|
|
|
|
|
- if (mCurTypeState != NULL)
|
|
|
|
|
|
+ auto parser = typeDecl->GetParser();
|
|
|
|
+ if ((parser != NULL) && (parser->mIsEmitted))
|
|
|
|
+ {
|
|
|
|
+ Fail("Type declarations are not allowed in emitted code", typeDecl);
|
|
|
|
+ }
|
|
|
|
+ else if (mCurTypeState != NULL)
|
|
{
|
|
{
|
|
mCurTypeState->mAnonymousTypeDecls.Add(typeDecl);
|
|
mCurTypeState->mAnonymousTypeDecls.Add(typeDecl);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
- {
|
|
|
|
- Fail("Type declarations are not allowed in emitted code", typeDecl);
|
|
|
|
|
|
+ {
|
|
|
|
+ Fail("Invalid use of anonymous type declaration", typeDecl);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|