diff --git a/include/parser/Parser.hpp b/include/parser/Parser.hpp index e8670f4..b423098 100644 --- a/include/parser/Parser.hpp +++ b/include/parser/Parser.hpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include #include @@ -212,6 +214,29 @@ class Parser { ); } + std::unique_ptr exprLoop() { + Token address = this->consume("loop"); + this->consume("("); + + std::unique_ptr initial = this->expression(); + this->consume(";"); + + std::unique_ptr condition = this->expression(); + this->consume(";"); + + std::unique_ptr postexpr = this->expression(); + this->consume(")"); + + std::unique_ptr body = this->expression(); + return std::make_unique( + std::make_unique(address), + std::move(initial), + std::move(condition), + std::move(postexpr), + std::move(body) + ); + } + std::unique_ptr exprIf() { Token address = this->consume("if"); this->consume("("); @@ -248,6 +273,10 @@ class Parser { std::make_unique(this->consume("false")), false ); + else if(this->isNext("maybe")) + expr = std::make_unique( + std::make_unique(this->consume("maybe")) + ); else if(this->isNext("nil")) expr = std::make_unique( std::make_unique(this->consume("nil"))