added the parsing of expression statements
This commit is contained in:
16
src/ast/statements/expression.cpp
Normal file
16
src/ast/statements/expression.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "expression.hpp"
|
||||
|
||||
namespace ast {
|
||||
|
||||
expression_stmt::expression_stmt(token::token token)
|
||||
: token(std::move(token)),
|
||||
expression(nullptr) {}
|
||||
|
||||
std::string expression_stmt::token_literal() const {
|
||||
return token.literal;
|
||||
}
|
||||
|
||||
expression_stmt::~expression_stmt() {
|
||||
delete expression;
|
||||
}
|
||||
} // namespace ast
|
15
src/ast/statements/expression.hpp
Normal file
15
src/ast/statements/expression.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "ast/ast.hpp"
|
||||
#include "token/token.hpp"
|
||||
|
||||
namespace ast {
|
||||
struct expression_stmt : statement {
|
||||
expression_stmt(token::token token);
|
||||
|
||||
token::token token;
|
||||
ast::expression* expression;
|
||||
|
||||
std::string token_literal() const override;
|
||||
|
||||
~expression_stmt();
|
||||
};
|
||||
} // namespace ast
|
Reference in New Issue
Block a user