written tests for infix expressions

This commit is contained in:
Karma Riuk
2025-07-11 09:07:33 +02:00
parent f038d30d77
commit 702c34a736
3 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
#include "infix.hpp"
#include "token/token.hpp"
namespace ast {
std::string infix_expr::token_literal() const {
return token.literal;
}
std::string infix_expr::str() const {
return left->str() + token.literal + right->str();
}
infix_expr::~infix_expr() {
delete left;
delete right;
};
} // namespace ast

View File

@@ -0,0 +1,17 @@
#pragma once
#include "ast/ast.hpp"
#include "token/token.hpp"
namespace ast {
struct infix_expr : expression {
token::token token;
expression* left;
std::string op;
expression* right;
std::string token_literal() const override;
std::string str() const override;
~infix_expr();
};
} // namespace ast