221 lines
5.0 KiB
C++
221 lines
5.0 KiB
C++
#include "ast_novel.h"
|
||
|
||
|
||
using namespace example_novel;
|
||
using namespace lib_syntax;
|
||
|
||
TextSection::TextSection(std::shared_ptr<const ExprRule> rule_bind)
|
||
: AbstractImpl(rule_bind) {}
|
||
|
||
QString TextSection::content() const
|
||
{
|
||
QString text;
|
||
for (auto& t : selfTokens()) {
|
||
text += t->token()->content() + " ";
|
||
}
|
||
return text;
|
||
}
|
||
|
||
int TextSection::typeMark() const { return (int)NovelNode::TextSection; }
|
||
|
||
bool TextSection::isAnonymous() const
|
||
{
|
||
return true;
|
||
}
|
||
|
||
QString TextSection::signature() const { return u8"::section"; }
|
||
|
||
PointRefers::PointRefers(std::shared_ptr<const ExprRule> rule_bind)
|
||
: AbstractImpl(rule_bind) {}
|
||
|
||
QString PointRefers::storyRefer() const { return story_refs; }
|
||
|
||
void example_novel::PointRefers::setStoryRefer(const QString& refer) {
|
||
this->story_refs = refer;
|
||
}
|
||
|
||
QString PointRefers::fragmentRefer() const { return fragment_ref; }
|
||
|
||
void example_novel::PointRefers::setFragmentRefer(const QString& refer) {
|
||
this->fragment_ref = refer;
|
||
}
|
||
|
||
QString PointRefers::referSignature() const {
|
||
return storyRefer() + u8"&" + fragmentRefer();
|
||
}
|
||
|
||
int PointRefers::typeMark() const { return (int)NovelNode::PointRefers; }
|
||
|
||
bool PointRefers::isAnonymous() const
|
||
{
|
||
return true;
|
||
}
|
||
|
||
QString PointRefers::signature() const {
|
||
QString signature = u8"@" + storyRefer() + u8"&" + fragmentRefer();
|
||
return parent()->signature() + signature;
|
||
}
|
||
|
||
|
||
PointDefines::PointDefines(std::shared_ptr<const ExprRule> rule_bind)
|
||
: AbstractImpl(rule_bind) {}
|
||
|
||
QString PointDefines::name() const { return name_store; }
|
||
|
||
void example_novel::PointDefines::setName(const QString& nm)
|
||
{
|
||
this->name_store = nm;
|
||
}
|
||
|
||
int PointDefines::typeMark() const { return (int)NovelNode::PointDefines; }
|
||
|
||
bool PointDefines::isAnonymous() const
|
||
{
|
||
return false;
|
||
}
|
||
|
||
QString PointDefines::signature() const { return parent()->signature() + u8"&" + name(); }
|
||
|
||
|
||
StoryDefine::StoryDefine(std::shared_ptr<const ExprRule> rule_bind)
|
||
: AbstractImpl(rule_bind), sort_index(0) {}
|
||
|
||
QString StoryDefine::name() const { return name_store; }
|
||
|
||
void example_novel::StoryDefine::setName(const QString& nm)
|
||
{
|
||
this->name_store = nm;
|
||
}
|
||
|
||
void example_novel::StoryDefine::setSort(int value) {
|
||
sort_index = value;
|
||
}
|
||
|
||
int StoryDefine::sort() const { return sort_index; }
|
||
|
||
int StoryDefine::typeMark() const { return (int)NovelNode::StoryDefine; }
|
||
|
||
bool StoryDefine::isAnonymous() const
|
||
{
|
||
return false;
|
||
}
|
||
|
||
QString StoryDefine::signature() const { return name(); }
|
||
|
||
#include "syntax_novel.h"
|
||
Document::Document(std::shared_ptr<const ExprRule> rule_bind)
|
||
: AbstractImpl(rule_bind) {}
|
||
|
||
int Document::typeMark() const { return (int)NovelNode::Document; }
|
||
|
||
bool Document::isAnonymous() const
|
||
{
|
||
return true;
|
||
}
|
||
|
||
QString Document::signature() const { return QString(u8"::document<%1>").arg(path()); }
|
||
|
||
AbstractImpl::AbstractImpl(std::shared_ptr<const ExprRule> rule_bind)
|
||
: ExprElement(rule_bind) {
|
||
parent_store.reset();
|
||
}
|
||
|
||
QList<std::shared_ptr<const ast_gen::TokenAccess> > AbstractImpl::selfTokens() const {
|
||
auto tokensx = ast_basic::ExprElement::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> AbstractImpl::parent() const
|
||
{
|
||
return this->parent_store.lock();
|
||
}
|
||
|
||
void AbstractImpl::setParent(std::shared_ptr<const ast_gen::SyntaxElement> inst)
|
||
{
|
||
this->parent_store = inst;
|
||
}
|
||
|
||
|
||
// ͨ<><CDA8> SyntaxElement <20>̳<EFBFBD>
|
||
std::shared_ptr<const ast_basic::IExprInst> AbstractImpl::bindExpression() const {
|
||
return shared_from_this();
|
||
}
|
||
|
||
QString AbstractImpl::path() const
|
||
{
|
||
return ast_basic::ExprElement::filePath();
|
||
}
|
||
|
||
VolumeDefine::VolumeDefine(std::shared_ptr<const ExprRule> rule_bind)
|
||
: AbstractImpl(rule_bind) {}
|
||
|
||
QString VolumeDefine::name() const { return name_store; }
|
||
|
||
void example_novel::VolumeDefine::setName(const QString& nm)
|
||
{
|
||
this->name_store = nm;
|
||
}
|
||
|
||
int VolumeDefine::typeMark() const { return (int)NovelNode::VolumeDefine; }
|
||
|
||
bool VolumeDefine::isAnonymous() const
|
||
{
|
||
return false;
|
||
}
|
||
|
||
QString VolumeDefine::signature() const { return name(); }
|
||
|
||
ArticleDefine::ArticleDefine(std::shared_ptr<const ExprRule> rule_bind)
|
||
: AbstractImpl(rule_bind) {}
|
||
|
||
QString ArticleDefine::name() const { return name_store; }
|
||
|
||
void example_novel::ArticleDefine::setName(const QString& nm)
|
||
{
|
||
this->name_store = nm;
|
||
}
|
||
|
||
int ArticleDefine::typeMark() const { return (int)NovelNode::ArticleDefine; }
|
||
|
||
bool ArticleDefine::isAnonymous() const
|
||
{
|
||
return false;
|
||
}
|
||
|
||
QString ArticleDefine::signature() const { return parent()->signature() + u8"&" + name(); }
|
||
|
||
RankDeclare::RankDeclare(std::shared_ptr<const ExprRule> rule)
|
||
: AbstractImpl(rule)
|
||
{
|
||
}
|
||
|
||
int example_novel::RankDeclare::rankNumber() const
|
||
{
|
||
return page_rank;
|
||
}
|
||
|
||
void example_novel::RankDeclare::setRank(int nums)
|
||
{
|
||
this->page_rank = nums;
|
||
}
|
||
|
||
int RankDeclare::typeMark() const
|
||
{
|
||
return (int)NovelNode::RankDeclaration;
|
||
}
|
||
|
||
bool RankDeclare::isAnonymous() const
|
||
{
|
||
return true;
|
||
}
|
||
|
||
QString RankDeclare::signature() const
|
||
{
|
||
return u8"::rank";
|
||
}
|