154 lines
4.4 KiB
C++
154 lines
4.4 KiB
C++
#include "ast_novel.h"
|
||
|
||
|
||
using namespace example_novel;
|
||
|
||
TextSection::TextSection(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
||
: AbstractImpl(rule_bind) {}
|
||
|
||
QString example_novel::TextSection::content() const
|
||
{
|
||
QString text;
|
||
for (auto& t : selfTokens()) {
|
||
text += t->token()->content() + " ";
|
||
}
|
||
return text;
|
||
}
|
||
|
||
int TextSection::typeMark() const { return (int)NovelNode::TextSection; }
|
||
|
||
bool example_novel::TextSection::isAnonymous() const
|
||
{
|
||
return true;
|
||
}
|
||
|
||
QString TextSection::signature() const { return u8"::section"; }
|
||
|
||
FragmentRefers::FragmentRefers(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
||
: AbstractImpl(rule_bind) {}
|
||
|
||
QString FragmentRefers::storyRefer() const { return selfTokens()[5]->token()->content(); }
|
||
|
||
QString FragmentRefers::fragmentRefer() const { return selfTokens()[3]->token()->content(); }
|
||
|
||
QString FragmentRefers::referSignature() const {
|
||
return storyRefer() + u8"&" + fragmentRefer();
|
||
}
|
||
|
||
int FragmentRefers::typeMark() const { return (int)NovelNode::FragmentRefer; }
|
||
|
||
bool example_novel::FragmentRefers::isAnonymous() const
|
||
{
|
||
return true;
|
||
}
|
||
|
||
QString FragmentRefers::signature() const {
|
||
QString signature = u8"@" + storyRefer() + u8"&" + fragmentRefer();
|
||
return parent()->signature() + signature;
|
||
}
|
||
|
||
FragmentDefine::FragmentDefine(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
||
: AbstractImpl(rule_bind) {}
|
||
|
||
QString FragmentDefine::name() const { return selfTokens()[2]->token()->content(); }
|
||
|
||
int FragmentDefine::typeMark() const { return (int)NovelNode::FragmentDefine; }
|
||
|
||
bool example_novel::FragmentDefine::isAnonymous() const
|
||
{
|
||
return false;
|
||
}
|
||
|
||
QString FragmentDefine::signature() const { return parent()->signature() + u8"&" + name(); }
|
||
|
||
StoryDefine::StoryDefine(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
||
: AbstractImpl(rule_bind) {}
|
||
|
||
QString StoryDefine::name() const { return selfTokens()[3]->token()->content(); }
|
||
|
||
int StoryDefine::sort() const { return selfTokens()[2]->token()->content().toInt(); }
|
||
|
||
int StoryDefine::typeMark() const { return (int)NovelNode::StoryDefine; }
|
||
|
||
bool example_novel::StoryDefine::isAnonymous() const
|
||
{
|
||
return false;
|
||
}
|
||
|
||
QString StoryDefine::signature() const { return name(); }
|
||
|
||
#include "syntax_novel.h"
|
||
Document::Document(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
||
: AbstractImpl(rule_bind) {}
|
||
|
||
int Document::typeMark() const { return (int)NovelNode::Document; }
|
||
|
||
bool example_novel::Document::isAnonymous() const
|
||
{
|
||
return true;
|
||
}
|
||
|
||
QString Document::signature() const { return QString(u8"::document<%1>").arg(path()); }
|
||
|
||
example_novel::AbstractImpl::AbstractImpl(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
||
: ExpressionElement(rule_bind) {}
|
||
|
||
QList<std::shared_ptr<const ast_gen::TokenAccess> > AbstractImpl::selfTokens() const {
|
||
auto tokensx = ast_basic::ExpressionElement::tokens();
|
||
QList<std::shared_ptr<const ast_gen::TokenAccess>> values;
|
||
for (auto xit : tokensx) {
|
||
values.append(std::make_shared<ast_gen::TokenAccess>(std::dynamic_pointer_cast<const ast_gen::SyntaxElement>(shared_from_this()), xit));
|
||
}
|
||
|
||
return values;
|
||
}
|
||
|
||
std::shared_ptr<const ast_gen::SyntaxElement> example_novel::AbstractImpl::parent() const
|
||
{
|
||
return this->parent_store;
|
||
}
|
||
|
||
void example_novel::AbstractImpl::setParent(std::shared_ptr<const ast_gen::SyntaxElement> inst)
|
||
{
|
||
this->parent_store = inst;
|
||
}
|
||
|
||
|
||
// ͨ<><CDA8> SyntaxElement <20>̳<EFBFBD>
|
||
std::shared_ptr<const ast_basic::Expression> example_novel::AbstractImpl::bindExpression() const {
|
||
return shared_from_this();
|
||
}
|
||
|
||
QString example_novel::AbstractImpl::path() const
|
||
{
|
||
return ast_basic::ExpressionElement::filePath();
|
||
}
|
||
|
||
VolumeDefine::VolumeDefine(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
||
: AbstractImpl(rule_bind) {}
|
||
|
||
QString VolumeDefine::name() const { return selfTokens()[2]->token()->content(); }
|
||
|
||
int VolumeDefine::typeMark() const { return (int)NovelNode::VolumeDefine; }
|
||
|
||
bool example_novel::VolumeDefine::isAnonymous() const
|
||
{
|
||
return false;
|
||
}
|
||
|
||
QString VolumeDefine::signature() const { return name(); }
|
||
|
||
ArticleDefine::ArticleDefine(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
||
: AbstractImpl(rule_bind) {}
|
||
|
||
QString ArticleDefine::name() const { return selfTokens()[2]->token()->content(); }
|
||
|
||
int ArticleDefine::typeMark() const { return (int)NovelNode::ArticleDefine; }
|
||
|
||
bool example_novel::ArticleDefine::isAnonymous() const
|
||
{
|
||
return false;
|
||
}
|
||
|
||
QString ArticleDefine::signature() const { return parent()->signature() + u8"&" + name(); }
|