Move Diagnostics to separate namespace
This commit is contained in:
@@ -99,7 +99,7 @@ namespace Porygon::Parser {
|
||||
Lexer::Next();
|
||||
return new SimpleToken(TokenKind::InequalityToken, this->_position - 2, 2);
|
||||
}
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedCharacter, this->_position - 1, 1);
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedCharacter, this->_position - 1, 1);
|
||||
return new SimpleToken(TokenKind::BadToken, this->_position - 1, 1);
|
||||
case '0':
|
||||
case '1':
|
||||
@@ -122,7 +122,7 @@ namespace Porygon::Parser {
|
||||
if (isalpha(c) || c > 255) {
|
||||
return LexIdentifierOrKeyword();
|
||||
}
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedCharacter, this->_position - 1, 1);
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedCharacter, this->_position - 1, 1);
|
||||
return new SimpleToken(TokenKind::BadToken, this->_position - 1, 1);
|
||||
}
|
||||
}
|
||||
@@ -289,7 +289,7 @@ namespace Porygon::Parser {
|
||||
}
|
||||
auto closeToken = this->Next();
|
||||
if (closeToken != c) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedCharacter, this->_position - 1, 1);
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedCharacter, this->_position - 1, 1);
|
||||
return new SimpleToken(TokenKind::BadToken, start, end - start + 1);
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ namespace Porygon::Parser {
|
||||
if (ControlCharacters.find(c) != ControlCharacters.end()) {
|
||||
stream << ControlCharacters.at(c);
|
||||
} else {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::InvalidStringControlCharacter,
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::InvalidStringControlCharacter,
|
||||
start + 1 + i, 1);
|
||||
stream << c;
|
||||
}
|
||||
|
||||
@@ -72,12 +72,12 @@ namespace Porygon::Parser {
|
||||
auto expression = this->ParseExpression(this->Next());
|
||||
|
||||
if (identifier->GetKind() != TokenKind::Identifier) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, identifier->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, identifier->GetStartPosition(),
|
||||
identifier->GetLength());
|
||||
return new ParsedBadStatement(identifier->GetStartPosition(), identifier->GetLength());
|
||||
}
|
||||
if (assignmentToken->GetKind() != TokenKind::AssignmentToken) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, identifier->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, identifier->GetStartPosition(),
|
||||
identifier->GetLength());
|
||||
return new ParsedBadStatement(identifier->GetStartPosition(), identifier->GetLength());
|
||||
}
|
||||
@@ -107,7 +107,7 @@ namespace Porygon::Parser {
|
||||
break;
|
||||
}
|
||||
if (nextKind == TokenKind::EndOfFile) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, next->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, next->GetStartPosition(),
|
||||
next->GetLength());
|
||||
break;
|
||||
}
|
||||
@@ -125,13 +125,13 @@ namespace Porygon::Parser {
|
||||
vector<TypedVariableIdentifier *> parameters;
|
||||
bool hasErrors = false;
|
||||
if (functionIdentifierToken->GetKind() != TokenKind::Identifier) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken,
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken,
|
||||
functionIdentifierToken->GetStartPosition(),
|
||||
functionIdentifierToken->GetLength());
|
||||
hasErrors = true;
|
||||
}
|
||||
if (openParenthesis->GetKind() != TokenKind::OpenParenthesis && !hasErrors) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken,
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken,
|
||||
openParenthesis->GetStartPosition(), openParenthesis->GetLength());
|
||||
hasErrors = true;
|
||||
}
|
||||
@@ -144,20 +144,20 @@ namespace Porygon::Parser {
|
||||
auto identifier = this->Next();
|
||||
auto next = this->Next();
|
||||
if (type->GetKind() != TokenKind::Identifier && !hasErrors) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, type->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, type->GetStartPosition(),
|
||||
type->GetLength());
|
||||
hasErrors = true;
|
||||
continue;
|
||||
}
|
||||
if (identifier->GetKind() != TokenKind::Identifier && !hasErrors) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, identifier->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, identifier->GetStartPosition(),
|
||||
identifier->GetLength());
|
||||
hasErrors = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type->GetKind() != TokenKind::Identifier || identifier->GetKind() != TokenKind::Identifier) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, type->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, type->GetStartPosition(),
|
||||
type->GetLength());
|
||||
hasErrors = true;
|
||||
continue;
|
||||
@@ -170,7 +170,7 @@ namespace Porygon::Parser {
|
||||
if (nextKind == TokenKind::CloseParenthesis || nextKind == TokenKind::EndOfFile) {
|
||||
break;
|
||||
} else if (nextKind != TokenKind::CommaToken && !hasErrors) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, next->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, next->GetStartPosition(),
|
||||
next->GetLength());
|
||||
hasErrors = true;
|
||||
}
|
||||
@@ -201,7 +201,7 @@ namespace Porygon::Parser {
|
||||
auto condition = this->ParseExpression(this->Next());
|
||||
auto next = this->Next();
|
||||
if (next->GetKind() != TokenKind::ThenKeyword) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, next->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, next->GetStartPosition(),
|
||||
next->GetLength());
|
||||
return new ParsedBadStatement(next->GetStartPosition(), next->GetLength());
|
||||
}
|
||||
@@ -385,7 +385,7 @@ namespace Porygon::Parser {
|
||||
case TokenKind::BadToken:
|
||||
return new BadExpression(current->GetStartPosition(), current->GetLength());
|
||||
default:
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, current->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, current->GetStartPosition(),
|
||||
current->GetLength());
|
||||
return new BadExpression(current->GetStartPosition(), current->GetLength());
|
||||
}
|
||||
@@ -396,7 +396,7 @@ namespace Porygon::Parser {
|
||||
auto expression = this->ParseExpression(next);
|
||||
auto closeToken = this->Next();
|
||||
if (closeToken->GetKind() != TokenKind::CloseParenthesis) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, closeToken->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, closeToken->GetStartPosition(),
|
||||
closeToken->GetLength());
|
||||
return new BadExpression(closeToken->GetStartPosition(), closeToken->GetLength());
|
||||
}
|
||||
@@ -414,7 +414,7 @@ namespace Porygon::Parser {
|
||||
} else {
|
||||
while (peekedKind != TokenKind::CloseParenthesis) {
|
||||
if (peekedKind == TokenKind::EndOfFile) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, peeked->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, peeked->GetStartPosition(),
|
||||
peeked->GetLength());
|
||||
return new BadExpression(peeked->GetStartPosition(), peeked->GetLength());
|
||||
}
|
||||
@@ -422,7 +422,7 @@ namespace Porygon::Parser {
|
||||
peeked = this->Next();
|
||||
peekedKind = peeked->GetKind();
|
||||
if (peekedKind != TokenKind::CloseParenthesis && peekedKind != TokenKind::CommaToken) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, peeked->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, peeked->GetStartPosition(),
|
||||
peeked->GetLength());
|
||||
return new BadExpression(peeked->GetStartPosition(), peeked->GetLength());
|
||||
}
|
||||
@@ -437,7 +437,7 @@ namespace Porygon::Parser {
|
||||
auto indexExpression = this->ParseExpression(this->Next());
|
||||
auto closeBracket = this->Next();
|
||||
if (closeBracket->GetKind() != TokenKind::CloseSquareBracket) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, closeBracket->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, closeBracket->GetStartPosition(),
|
||||
closeBracket->GetLength());
|
||||
return new BadExpression(closeBracket->GetStartPosition(), closeBracket->GetLength());
|
||||
}
|
||||
@@ -449,7 +449,7 @@ namespace Porygon::Parser {
|
||||
this->Next(); // consume '.' token
|
||||
auto identifier = this->Next();
|
||||
if (identifier->GetKind() != TokenKind::Identifier) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, identifier->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, identifier->GetStartPosition(),
|
||||
identifier->GetLength());
|
||||
return new BadExpression(indexingExpression->GetStartPosition(),
|
||||
identifier->GetEndPosition() - indexingExpression->GetStartPosition());
|
||||
@@ -481,7 +481,7 @@ namespace Porygon::Parser {
|
||||
n = this->Next();
|
||||
if (n->GetKind() != TokenKind::CommaToken && n->GetKind() != TokenKind::CloseCurlyBracket &&
|
||||
!hasErrors) {
|
||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, n->GetStartPosition(),
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, n->GetStartPosition(),
|
||||
n->GetLength());
|
||||
hasErrors = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user