Added basic vector<len, Ty>
This commit is contained in:
@@ -210,7 +210,7 @@ namespace PashaBibko::LXC::Parser
|
||||
return Util::FunctionFail<ParserError>(); // <- TODO: Make an actual error
|
||||
|
||||
// Checks for a default value for the variable //
|
||||
const Lexer::Token* varAssign = ctx.Peek();
|
||||
const Lexer::Token* varAssign = ctx.Advance();
|
||||
if (varAssign == nullptr)
|
||||
return Internal::CreateNode<AST::VarDeclaration>(varNameStr);
|
||||
|
||||
@@ -254,36 +254,31 @@ namespace PashaBibko::LXC::Parser
|
||||
if (paramsStart == nullptr )
|
||||
return Util::FunctionFail<ParserError>(); // <- TODO: Make an actual error
|
||||
|
||||
// Parses the parameters of the function //
|
||||
if (paramsStart->type == Lexer::Token::Identifier && paramsStart->Str() == "void")
|
||||
{ /* No parameters/arguments for the function */}
|
||||
|
||||
// Loops over the parameters/arguments of the function declaration //
|
||||
else
|
||||
while (ctx.At()->type != Lexer::Token::CloseParen)
|
||||
{
|
||||
while (ctx.At()->type != Lexer::Token::CloseParen)
|
||||
{
|
||||
// Checks for parameter pattern: identifier, identifier //
|
||||
if (!ctx.Expect(std::array{ Lexer::Token::Identifier, Lexer::Token::Colon, Lexer::Token::Identifier }))
|
||||
return Util::FunctionFail<ParserError>(); // <- TODO: Make an actual error
|
||||
|
||||
const Lexer::Token* paramType = ctx.At();
|
||||
const Lexer::Token* paramName = ctx.Advance(2); // Skips over seperating colon
|
||||
|
||||
currentFunction.funcParams.emplace_back(paramType->Str(), paramName->Str());
|
||||
|
||||
// Expects a comma or close bracket for the next token //
|
||||
const Lexer::Token* end = ctx.Advance();
|
||||
if (end == nullptr)
|
||||
return Util::FunctionFail<ParserError>(); // <- TODO: Make an actual error
|
||||
|
||||
if (end->type == Lexer::Token::Comma || end->type == Lexer::Token::CloseParen)
|
||||
continue;
|
||||
|
||||
// Checks for parameter pattern: identifier, identifier //
|
||||
if (!ctx.Expect(std::array{ Lexer::Token::Identifier, Lexer::Token::Colon, Lexer::Token::Identifier }))
|
||||
return Util::FunctionFail<ParserError>(); // <- TODO: Make an actual error
|
||||
}
|
||||
|
||||
const Lexer::Token* paramType = ctx.At();
|
||||
const Lexer::Token* paramName = ctx.Advance(2); // Skips over seperating colon
|
||||
|
||||
currentFunction.funcParams.emplace_back(paramType->Str(), paramName->Str());
|
||||
|
||||
// Expects a comma or close bracket for the next token //
|
||||
const Lexer::Token* end = ctx.Advance();
|
||||
if (end == nullptr)
|
||||
return Util::FunctionFail<ParserError>(); // <- TODO: Make an actual error
|
||||
|
||||
if (end->type == Lexer::Token::Comma || end->type == Lexer::Token::CloseParen)
|
||||
continue;
|
||||
|
||||
return Util::FunctionFail<ParserError>(); // <- TODO: Make an actual error
|
||||
}
|
||||
|
||||
// Adcances over close paren and open brace //
|
||||
ctx.Advance(2);
|
||||
|
||||
// Parses the function body //
|
||||
const Lexer::Token* current = ctx.At();
|
||||
while (current != nullptr)
|
||||
@@ -301,9 +296,7 @@ namespace PashaBibko::LXC::Parser
|
||||
return Util::FunctionFail<ParserError>(node.Error()); // Fowards the error
|
||||
|
||||
currentFunction.contents.emplace_back(std::move(node.Result()));
|
||||
|
||||
// Advances to the next token //
|
||||
current = ctx.Advance();
|
||||
current = ctx.At();
|
||||
}
|
||||
|
||||
return Util::FunctionFail<ParserError>(); // <- TODO: Make an actual error
|
||||
|
||||
Reference in New Issue
Block a user