can now parse prefix expressions!
This commit is contained in:
19
src/ast/expressions/prefix.cpp
Normal file
19
src/ast/expressions/prefix.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "prefix.hpp"
|
||||
|
||||
#include "token/token.hpp"
|
||||
|
||||
namespace ast {
|
||||
|
||||
prefix_expr::prefix_expr(token::token token, std::string op)
|
||||
: token(std::move(token)),
|
||||
op(op),
|
||||
right(nullptr) {}
|
||||
|
||||
std::string prefix_expr::token_literal() const {
|
||||
return token.literal;
|
||||
}
|
||||
|
||||
std::string prefix_expr::str() const {
|
||||
return token.literal + right->str();
|
||||
}
|
||||
} // namespace ast
|
Reference in New Issue
Block a user