Fix parametered functions skipping a token
This commit is contained in:
parent
7ed53193de
commit
d385a9e3ee
|
@ -100,6 +100,7 @@ BoundStatement *Binder::BindFunctionDeclarationStatement(ParsedStatement *statem
|
||||||
auto type = make_shared<FunctionScriptType>(returnType, parameterTypes, parameterKeys);
|
auto type = make_shared<FunctionScriptType>(returnType, parameterTypes, parameterKeys);
|
||||||
auto assignment = this->_scope->AssignVariable(identifier.GetHash(), type);
|
auto assignment = this->_scope->AssignVariable(identifier.GetHash(), type);
|
||||||
if (assignment.GetResult() != VariableAssignmentResult::Ok){
|
if (assignment.GetResult() != VariableAssignmentResult::Ok){
|
||||||
|
this -> _scriptData -> Diagnostics -> LogError(DiagnosticCode::CantAssignVariable, statement->GetStartPosition(), statement->GetLength());
|
||||||
return new BoundBadStatement();
|
return new BoundBadStatement();
|
||||||
}
|
}
|
||||||
auto boundBlock = this -> BindBlockStatement(functionStatement->GetBlock());
|
auto boundBlock = this -> BindBlockStatement(functionStatement->GetBlock());
|
||||||
|
|
|
@ -195,6 +195,8 @@ ParsedExpression* Parser::ParseExpression(IToken* current){
|
||||||
} else {
|
} else {
|
||||||
//TODO: index period expression
|
//TODO: index period expression
|
||||||
}
|
}
|
||||||
|
if (this -> _position >= this->_tokens.size())
|
||||||
|
break;
|
||||||
peekKind = this->Peek()->GetKind();
|
peekKind = this->Peek()->GetKind();
|
||||||
}
|
}
|
||||||
return expression;
|
return expression;
|
||||||
|
@ -331,20 +333,23 @@ ParsedExpression *Parser::ParseFunctionCallExpression(ParsedExpression* function
|
||||||
vector<ParsedExpression*> parameters;
|
vector<ParsedExpression*> parameters;
|
||||||
auto peeked = this -> Peek();
|
auto peeked = this -> Peek();
|
||||||
auto peekedKind = peeked->GetKind();
|
auto peekedKind = peeked->GetKind();
|
||||||
while (peekedKind != TokenKind::CloseParenthesis){
|
if (peekedKind == TokenKind::CloseParenthesis){
|
||||||
if (peekedKind == TokenKind ::EndOfFile){
|
this->Next();
|
||||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, peeked->GetStartPosition(), peeked->GetLength());
|
} else{
|
||||||
return new BadExpression(peeked->GetStartPosition(), peeked->GetLength());
|
while (peekedKind != TokenKind::CloseParenthesis){
|
||||||
}
|
if (peekedKind == TokenKind ::EndOfFile){
|
||||||
parameters.push_back(this->ParseExpression(this->Next()));
|
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, peeked->GetStartPosition(), peeked->GetLength());
|
||||||
peeked = this -> Next() ;
|
return new BadExpression(peeked->GetStartPosition(), peeked->GetLength());
|
||||||
peekedKind = peeked->GetKind();
|
}
|
||||||
if (peekedKind != TokenKind::CloseParenthesis && peekedKind != TokenKind::CommaToken){
|
parameters.push_back(this->ParseExpression(this->Next()));
|
||||||
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, peeked->GetStartPosition(), peeked->GetLength());
|
peeked = this -> Next() ;
|
||||||
return new BadExpression(peeked->GetStartPosition(), peeked->GetLength());
|
peekedKind = peeked->GetKind();
|
||||||
|
if (peekedKind != TokenKind::CloseParenthesis && peekedKind != TokenKind::CommaToken){
|
||||||
|
this->ScriptData->Diagnostics->LogError(DiagnosticCode::UnexpectedToken, peeked->GetStartPosition(), peeked->GetLength());
|
||||||
|
return new BadExpression(peeked->GetStartPosition(), peeked->GetLength());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this -> Next();
|
|
||||||
auto start = functionExpression->GetStartPosition();
|
auto start = functionExpression->GetStartPosition();
|
||||||
return new FunctionCallExpression(functionExpression, parameters, start, peeked->GetEndPosition() - start);
|
return new FunctionCallExpression(functionExpression, parameters, start, peeked->GetEndPosition() - start);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue