2024-03-17 07:58:28 +00:00
|
|
|
|
#include "ast_basic.h"
|
2024-06-18 17:09:45 +00:00
|
|
|
|
#include <QDebug>
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
|
|
|
|
using namespace ast_basic;
|
|
|
|
|
using namespace lib_token;
|
|
|
|
|
using namespace lib_syntax;
|
|
|
|
|
|
2025-02-04 14:26:34 +00:00
|
|
|
|
ExprInstance::ExprInstance(std::shared_ptr<const ExprRule> bind) : _expr_rule(bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2025-02-04 14:26:34 +00:00
|
|
|
|
std::shared_ptr<const ExprRule> ExprInstance::definedRule() const {
|
2024-06-27 04:55:07 +00:00
|
|
|
|
return _expr_rule;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-02-04 14:26:34 +00:00
|
|
|
|
QString ExprInstance::filePath() const {
|
2024-06-27 04:55:07 +00:00
|
|
|
|
if (!tokens_bind.size())
|
|
|
|
|
throw new SyntaxException(u8"InternalError[0x0002]һ<><D2BB><EFBFBD>յķǷ<C4B7><C7B7><EFBFBD>Ч<EFBFBD>ڵ<EFBFBD>");
|
|
|
|
|
|
|
|
|
|
return tokens_bind.first()->file();
|
2024-06-18 03:54:36 +00:00
|
|
|
|
}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2025-02-04 14:26:34 +00:00
|
|
|
|
void ExprInstance::addToken(std::shared_ptr<const IToken> token_inst) {
|
2024-06-27 04:55:07 +00:00
|
|
|
|
this->tokens_bind.append(token_inst);
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-02-04 14:26:34 +00:00
|
|
|
|
QList<std::shared_ptr<const IExprInst>> ExprInstance::children() const {
|
2024-06-27 04:55:07 +00:00
|
|
|
|
return this->children_store;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2025-02-04 14:26:34 +00:00
|
|
|
|
void ExprInstance::addChild(std::shared_ptr<const IExprInst> inst) {
|
2024-06-27 04:55:07 +00:00
|
|
|
|
this->children_store.append(inst);
|
2024-06-18 03:54:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-02-04 14:26:34 +00:00
|
|
|
|
QList<std::shared_ptr<const IToken>> ExprInstance::tokens() const {
|
2024-06-27 04:55:07 +00:00
|
|
|
|
return this->tokens_bind;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|