diff --git a/src/n8/parser/Parser.cpp b/src/n8/parser/Parser.cpp index acf5247..707f8df 100644 --- a/src/n8/parser/Parser.cpp +++ b/src/n8/parser/Parser.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -996,6 +997,26 @@ std::shared_ptr Parser::stmtTest() { ); } +std::shared_ptr Parser::stmtUse() { + Token address = this->consume("use"); + std::shared_ptr libName = this->expression(); + std::shared_ptr libVersion = nullptr; + + if(this->peek().getImage() == "@") { + this->consume("@"); + libVersion = this->expression(); + } + + if(this->isNext(";", TokenType::OPERATOR)) + this->consume(";"); + + return std::make_shared( + std::make_shared(address), + std::move(libName), + std::move(libVersion) + ); +} + std::shared_ptr Parser::stmtWait() { Token address = this->consume("wait"); @@ -1020,6 +1041,8 @@ std::shared_ptr Parser::statement() { return this->stmtThrow(); else if(this->isNext("test", TokenType::KEYWORD)) return this->stmtTest(); + else if(this->isNext("use", TokenType::KEYWORD)) + return this->stmtUse(); else if(this->isNext("wait", TokenType::KEYWORD)) return this->stmtWait();