WsParser_VS/libSyntax/ast_basic.cpp

36 lines
953 B
C++

#include "ast_basic.h"
#include <QDebug>
using namespace ast_basic;
using namespace lib_token;
using namespace lib_syntax;
ExpressionElement::ExpressionElement(std::shared_ptr<const ExprRule> bind) : _expr_rule(bind) {}
std::shared_ptr<const ExprRule> ExpressionElement::definedRule() const {
return _expr_rule;
}
QString ExpressionElement::filePath() const {
if (!tokens_bind.size())
throw new SyntaxException(u8"InternalError[0x0002]Ò»¸ö¿ÕµÄ·Ç·¨ÎÞЧ½Úµã");
return tokens_bind.first()->file();
}
void ExpressionElement::addToken(std::shared_ptr<const IToken> token_inst) {
this->tokens_bind.append(token_inst);
}
QList<std::shared_ptr<const IExprInst>> ExpressionElement::children() const {
return this->children_store;
}
void ExpressionElement::addChild(std::shared_ptr<const IExprInst> inst) {
this->children_store.append(inst);
}
QList<std::shared_ptr<const IToken>> ExpressionElement::tokens() const {
return this->tokens_bind;
}