#include "ast_basic.h" #include using namespace ast_basic; using namespace lib_token; using namespace lib_syntax; ExpressionElement::ExpressionElement(std::shared_ptr bind) : _expr_rule(bind) {} std::shared_ptr ast_basic::ExpressionElement::definedRule() const { return _expr_rule; } QString ast_basic::ExpressionElement::filePath() const { if(tokens_bind.size()) throw new SyntaxException(u8"InternalError[0x0002]一个空的非法无效节点"); return tokens_bind.first()->file(); } void ast_basic::ExpressionElement::tokensReset(const QList>& list) { this->tokens_bind = list; } void ast_basic::ExpressionElement::addToken(std::shared_ptr token_inst) { this->tokens_bind.append(token_inst); } QList> ast_basic::ExpressionElement::children() const { return this->children_store; } void ast_basic::ExpressionElement::addChild(std::shared_ptr inst) { this->children_store.append(inst); } QList> ExpressionElement::tokens() const { return this->tokens_bind; } std::shared_ptr ast_basic::ExpressionContext::currentInst() const { if(expression_stack.size()) return expression_stack.last(); return nullptr; } void ast_basic::ExpressionContext::pushInst(std::shared_ptr current_inst) { if(!expression_stack.size() || expression_stack.last() != current_inst) expression_stack.append(current_inst); } std::shared_ptr ast_basic::ExpressionContext::popInst() { auto lastx = expression_stack.takeLast(); return lastx; } std::shared_ptr ast_basic::ExpressionContext::currentExpressionRule() const { if(rule_stack.size()) return rule_stack.last(); return nullptr; } void ast_basic::ExpressionContext::pushExpressionRule(std::shared_ptr inst) { if(!rule_stack.size() || rule_stack.last() != inst) rule_stack.append(inst); } std::shared_ptr ast_basic::ExpressionContext::popExpressionRule() { return rule_stack.takeLast(); }