Fixes several valgrind spotted issues.
This commit is contained in:
@@ -49,7 +49,6 @@ namespace MalachScript::Parser {
|
||||
const auto* current = _currentToken;
|
||||
auto start = current->GetSpan().GetStart();
|
||||
bool lookingForClass = true;
|
||||
bool encounteredError = false;
|
||||
while (lookingForClass) {
|
||||
switch (current->GetKind()) {
|
||||
case LexTokenKind::SharedKeyword: break;
|
||||
@@ -91,8 +90,7 @@ namespace MalachScript::Parser {
|
||||
inherits.push_back(id);
|
||||
PROGRESS_TOKEN(current);
|
||||
}
|
||||
if (!encounteredError && current->GetKind() != LexTokenKind::OpenCurlyParenthesisSymbol) {
|
||||
encounteredError = true;
|
||||
if (current->GetKind() != LexTokenKind::OpenCurlyParenthesisSymbol) {
|
||||
LogError(Diagnostics::DiagnosticType::UnexpectedToken, current->GetSpan());
|
||||
}
|
||||
// Intentionally don't break so we continue into the inner body statement.
|
||||
@@ -105,7 +103,7 @@ namespace MalachScript::Parser {
|
||||
PROGRESS_TOKEN(current);
|
||||
break;
|
||||
}
|
||||
const ParsedStatement* statement;
|
||||
const ParsedStatement* statement = nullptr;
|
||||
// TODO: Sort by
|
||||
if (!ParseVirtProp(statement) && !ParseFunc(statement) && !ParseVar(statement) &&
|
||||
!ParseFuncDef(statement)) {
|
||||
@@ -154,7 +152,7 @@ namespace MalachScript::Parser {
|
||||
if (!ParseIdentifier(identifier, _currentToken)) {
|
||||
LogError(Diagnostics::DiagnosticType::UnexpectedToken, _currentToken->GetSpan());
|
||||
}
|
||||
auto script = ParseScript();
|
||||
const auto *script = ParseScript();
|
||||
auto end = _currentToken->GetSpan().GetEnd();
|
||||
PROGRESS_TOKEN(_currentToken);
|
||||
out = new ParsedNamespaceStatement(TextSpan(start, end), identifier, script);
|
||||
@@ -214,7 +212,7 @@ namespace MalachScript::Parser {
|
||||
PROGRESS_TOKEN(_currentToken);
|
||||
}
|
||||
bool lookingForFuncAttr = true;
|
||||
FuncAttr funcAttr;
|
||||
FuncAttr funcAttr = FuncAttr::None;
|
||||
while (lookingForFuncAttr) {
|
||||
switch (_currentToken->GetKind()) {
|
||||
case LexTokenKind::OverrideKeyword:
|
||||
@@ -325,7 +323,8 @@ namespace MalachScript::Parser {
|
||||
}
|
||||
auto start = currentToken->GetSpan().GetStart();
|
||||
PROGRESS_TOKEN(currentToken);
|
||||
std::vector<ParsedParamListStatement::ParsedParameter> parameters;
|
||||
std::vector<const ParsedParamListStatement::ParsedParameter*> parameters;
|
||||
|
||||
if (currentToken->GetKind() == LexTokenKind::VoidKeyword) {
|
||||
PROGRESS_TOKEN(currentToken);
|
||||
if (currentToken->GetKind() != LexTokenKind::CloseParenthesisSymbol) {
|
||||
@@ -334,20 +333,28 @@ namespace MalachScript::Parser {
|
||||
PROGRESS_TOKEN(currentToken);
|
||||
out = new ParsedParamListStatement(TextSpan(start, currentToken->GetSpan().GetEnd()), parameters);
|
||||
return true;
|
||||
} else if (currentToken->GetKind() == LexTokenKind::CloseParenthesisSymbol) {
|
||||
} if (currentToken->GetKind() == LexTokenKind::CloseParenthesisSymbol) {
|
||||
out = new ParsedParamListStatement(TextSpan(start, currentToken->GetSpan().GetEnd()), parameters);
|
||||
PROGRESS_TOKEN(currentToken);
|
||||
return true;
|
||||
}
|
||||
while (true) {
|
||||
parameters.emplace_back();
|
||||
auto& parameter = parameters.at(parameters.size() - 1);
|
||||
if (!ParseType((const ParsedStatement*&)parameter.GetTypeStatement(), currentToken)) {
|
||||
const ParsedStatement* typeStatement = nullptr;
|
||||
TypeMod typeMod = TypeMod::None;
|
||||
Identifier identifier;
|
||||
const ParsedExpression* defaultExpression = nullptr;
|
||||
|
||||
if (!ParseType(typeStatement, currentToken)) {
|
||||
LogError(Diagnostics::DiagnosticType::UnexpectedToken, currentToken->GetSpan());
|
||||
}
|
||||
ParseTypeMod(parameter.GetTypeMod(), currentToken);
|
||||
ParseIdentifier(parameter.GetIdentifier(), currentToken);
|
||||
ParseTypeMod(typeMod, currentToken);
|
||||
ParseIdentifier(identifier, currentToken);
|
||||
PROGRESS_TOKEN(currentToken);
|
||||
// TODO: Default expression
|
||||
|
||||
parameters.push_back(new ParsedParamListStatement::ParsedParameter(
|
||||
dynamic_cast<const ParsedTypeStatement*>(typeStatement), typeMod, identifier, defaultExpression));
|
||||
|
||||
if (currentToken->GetKind() != LexTokenKind::CommaSymbol) {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user