This commit is contained in:
codeboss 2024-07-28 14:41:54 +08:00
parent c2c6f0a083
commit 8b7ebd11ac
6 changed files with 15 additions and 15 deletions

View File

@ -5,32 +5,32 @@ using namespace ast_basic;
using namespace lib_token; using namespace lib_token;
using namespace lib_syntax; using namespace lib_syntax;
ExpressionElement::ExpressionElement(std::shared_ptr<const ExprRule> bind) : _expr_rule(bind) {} ExprElement::ExprElement(std::shared_ptr<const ExprRule> bind) : _expr_rule(bind) {}
std::shared_ptr<const ExprRule> ExpressionElement::definedRule() const { std::shared_ptr<const ExprRule> ExprElement::definedRule() const {
return _expr_rule; return _expr_rule;
} }
QString ExpressionElement::filePath() const { QString ExprElement::filePath() const {
if (!tokens_bind.size()) if (!tokens_bind.size())
throw new SyntaxException(u8"InternalError[0x0002]一个空的非法无效节点"); throw new SyntaxException(u8"InternalError[0x0002]一个空的非法无效节点");
return tokens_bind.first()->file(); return tokens_bind.first()->file();
} }
void ExpressionElement::addToken(std::shared_ptr<const IToken> token_inst) { void ExprElement::addToken(std::shared_ptr<const IToken> token_inst) {
this->tokens_bind.append(token_inst); this->tokens_bind.append(token_inst);
} }
QList<std::shared_ptr<const IExprInst>> ExpressionElement::children() const { QList<std::shared_ptr<const IExprInst>> ExprElement::children() const {
return this->children_store; return this->children_store;
} }
void ExpressionElement::addChild(std::shared_ptr<const IExprInst> inst) { void ExprElement::addChild(std::shared_ptr<const IExprInst> inst) {
this->children_store.append(inst); this->children_store.append(inst);
} }
QList<std::shared_ptr<const IToken>> ExpressionElement::tokens() const { QList<std::shared_ptr<const IToken>> ExprElement::tokens() const {
return this->tokens_bind; return this->tokens_bind;
} }

View File

@ -57,14 +57,14 @@ namespace ast_basic {
/** /**
* @brief * @brief
*/ */
class LIBSYNTAX_EXPORT ExpressionElement : public ast_basic::IExprInst, public std::enable_shared_from_this<ExpressionElement> { class LIBSYNTAX_EXPORT ExprElement : public ast_basic::IExprInst, public std::enable_shared_from_this<ExprElement> {
private: private:
std::shared_ptr<const lib_syntax::ExprRule> _expr_rule; std::shared_ptr<const lib_syntax::ExprRule> _expr_rule;
QList<std::shared_ptr<const IExprInst>> children_store; QList<std::shared_ptr<const IExprInst>> children_store;
QList<std::shared_ptr<const lib_token::IToken>> tokens_bind; QList<std::shared_ptr<const lib_token::IToken>> tokens_bind;
public: public:
ExpressionElement(std::shared_ptr<const lib_syntax::ExprRule> bind); ExprElement(std::shared_ptr<const lib_syntax::ExprRule> bind);
// 通过 Expression 继承 // 通过 Expression 继承
std::shared_ptr<const lib_syntax::ExprRule> definedRule() const override; std::shared_ptr<const lib_syntax::ExprRule> definedRule() const override;

View File

@ -107,7 +107,7 @@ namespace ast_gen
QString names_store; QString names_store;
QHash<QString, std::shared_ptr<const SyntaxElement>> node_cache; QHash<QString, std::shared_ptr<const SyntaxElement>> node_cache;
std::shared_ptr<ast_basic::IExprInst> bind_exprs = std::make_shared<ast_basic::ExpressionElement>(nullptr); std::shared_ptr<ast_basic::IExprInst> bind_exprs = std::make_shared<ast_basic::ExprElement>(nullptr);
public: public:
static GlobalElement* UniquePtr; static GlobalElement* UniquePtr;

View File

@ -121,10 +121,10 @@ void Document::cacheLoad()
} }
AbstractImpl::AbstractImpl(std::shared_ptr<const ExprRule> rule_bind) AbstractImpl::AbstractImpl(std::shared_ptr<const ExprRule> rule_bind)
: ExpressionElement(rule_bind) { parent_store.reset(); } : ExprElement(rule_bind) { parent_store.reset(); }
QList<std::shared_ptr<const ast_gen::TokenAccess> > AbstractImpl::selfTokens() const { QList<std::shared_ptr<const ast_gen::TokenAccess> > AbstractImpl::selfTokens() const {
auto tokensx = ast_basic::ExpressionElement::tokens(); auto tokensx = ast_basic::ExprElement::tokens();
QList<std::shared_ptr<const ast_gen::TokenAccess>> values; QList<std::shared_ptr<const ast_gen::TokenAccess>> values;
for (auto xit : tokensx) { for (auto xit : tokensx) {
values.append(std::make_shared<ast_gen::TokenAccess>(std::dynamic_pointer_cast<const ast_gen::SyntaxElement>(shared_from_this()), xit)); values.append(std::make_shared<ast_gen::TokenAccess>(std::dynamic_pointer_cast<const ast_gen::SyntaxElement>(shared_from_this()), xit));
@ -151,7 +151,7 @@ std::shared_ptr<const ast_basic::IExprInst> AbstractImpl::bindExpression() const
QString AbstractImpl::path() const QString AbstractImpl::path() const
{ {
return ast_basic::ExpressionElement::filePath(); return ast_basic::ExprElement::filePath();
} }
VolumeDefine::VolumeDefine(std::shared_ptr<const ExprRule> rule_bind) VolumeDefine::VolumeDefine(std::shared_ptr<const ExprRule> rule_bind)

View File

@ -16,7 +16,7 @@ namespace example_novel
RankDeclaration = 8, RankDeclaration = 8,
}; };
class LIBSYNTAX_EXPORT AbstractImpl : public ast_basic::ExpressionElement, public ast_gen::SyntaxElement { class LIBSYNTAX_EXPORT AbstractImpl : public ast_basic::ExprElement, public ast_gen::SyntaxElement {
private: private:
std::weak_ptr<const SyntaxElement> parent_store; std::weak_ptr<const SyntaxElement> parent_store;

View File

@ -7,7 +7,7 @@
#include <functional> #include <functional>
namespace ast_basic { namespace ast_basic {
class IExprInst; class IExprInst;
class ExpressionElement; class ExprElement;
} }
namespace lib_syntax { namespace lib_syntax {