renamed let to let_stmt
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
#include "let.hpp"
|
||||
|
||||
namespace ast {
|
||||
let::let(token::token token)
|
||||
let_stmt::let_stmt(token::token token)
|
||||
: token(std::move(token)),
|
||||
name(nullptr),
|
||||
value(nullptr) {}
|
||||
|
||||
std::string let::token_literal() const {
|
||||
std::string let_stmt::token_literal() const {
|
||||
return token.literal;
|
||||
}
|
||||
|
||||
let::~let() {
|
||||
let_stmt::~let_stmt() {
|
||||
delete name;
|
||||
delete value;
|
||||
};
|
||||
|
@@ -5,8 +5,8 @@
|
||||
#include "token/token.hpp"
|
||||
|
||||
namespace ast {
|
||||
struct let : statement {
|
||||
let(token::token token);
|
||||
struct let_stmt : statement {
|
||||
let_stmt(token::token token);
|
||||
|
||||
token::token token;
|
||||
identifier* name;
|
||||
@@ -14,6 +14,6 @@ namespace ast {
|
||||
|
||||
std::string token_literal() const override;
|
||||
|
||||
~let();
|
||||
~let_stmt();
|
||||
};
|
||||
} // namespace ast
|
||||
|
@@ -35,6 +35,8 @@ namespace parser {
|
||||
switch (current.type) {
|
||||
case token::type::LET:
|
||||
return parse_let();
|
||||
case token::type::RETURN:
|
||||
return parse_return();
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
@@ -49,8 +51,8 @@ namespace parser {
|
||||
return false;
|
||||
}
|
||||
|
||||
ast::let* parser::parse_let() {
|
||||
ast::let* stmt = new ast::let(current);
|
||||
ast::let_stmt* parser::parse_let() {
|
||||
ast::let_stmt* stmt = new ast::let_stmt(current);
|
||||
|
||||
if (!expect_next(token::type::IDENTIFIER)) {
|
||||
delete stmt;
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include "ast/ast.hpp"
|
||||
#include "ast/errors/error.hpp"
|
||||
#include "ast/statements/let.hpp"
|
||||
#include "ast/statements/return.hpp"
|
||||
#include "lexer/lexer.hpp"
|
||||
#include "token/token.hpp"
|
||||
|
||||
@@ -20,7 +21,8 @@ namespace parser {
|
||||
|
||||
void next_token();
|
||||
ast::statement* parse_statement();
|
||||
ast::let* parse_let();
|
||||
ast::let_stmt* parse_let();
|
||||
ast::return_stmt* parse_return();
|
||||
bool expect_next(token::type);
|
||||
void next_error(token::type);
|
||||
};
|
||||
|
Reference in New Issue
Block a user