2024-03-17 07:58:28 +00:00
|
|
|
|
#include "ast_novel.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace example_novel;
|
2024-06-20 13:36:46 +00:00
|
|
|
|
using namespace lib_syntax;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-07-12 04:53:43 +00:00
|
|
|
|
TextSection::TextSection(std::shared_ptr<const ExprRule> rule_bind)
|
2024-06-18 03:54:36 +00:00
|
|
|
|
: AbstractImpl(rule_bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-20 13:36:46 +00:00
|
|
|
|
QString TextSection::content() const
|
2024-03-17 07:58:28 +00:00
|
|
|
|
{
|
2024-07-28 08:37:31 +00:00
|
|
|
|
QString text;
|
|
|
|
|
for (auto& t : selfTokens()) {
|
|
|
|
|
text += t->token()->content() + " ";
|
|
|
|
|
}
|
|
|
|
|
return text;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TextSection::typeMark() const { return (int)NovelNode::TextSection; }
|
|
|
|
|
|
2024-06-20 13:36:46 +00:00
|
|
|
|
bool TextSection::isAnonymous() const
|
2024-03-17 07:58:28 +00:00
|
|
|
|
{
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return true;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString TextSection::signature() const { return u8"::section"; }
|
|
|
|
|
|
2025-02-02 14:29:03 +00:00
|
|
|
|
PointRefers::PointRefers(std::shared_ptr<const ExprRule> rule_bind)
|
2024-06-18 03:54:36 +00:00
|
|
|
|
: AbstractImpl(rule_bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2025-02-02 14:29:03 +00:00
|
|
|
|
QString PointRefers::storyRefer() const { return story_refs; }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2025-02-02 14:29:03 +00:00
|
|
|
|
void example_novel::PointRefers::setStoryRefer(const QString& refer) {
|
2024-07-28 08:37:31 +00:00
|
|
|
|
this->story_refs = refer;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-02 14:29:03 +00:00
|
|
|
|
QString PointRefers::fragmentRefer() const { return fragment_ref; }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2025-02-02 14:29:03 +00:00
|
|
|
|
void example_novel::PointRefers::setFragmentRefer(const QString& refer) {
|
2024-07-28 08:37:31 +00:00
|
|
|
|
this->fragment_ref = refer;
|
2024-06-18 04:44:18 +00:00
|
|
|
|
}
|
2024-07-28 08:37:31 +00:00
|
|
|
|
|
2025-02-02 14:29:03 +00:00
|
|
|
|
QString PointRefers::referSignature() const {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return storyRefer() + u8"&" + fragmentRefer();
|
2024-03-31 05:59:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-02-02 14:29:03 +00:00
|
|
|
|
int PointRefers::typeMark() const { return (int)NovelNode::PointRefers; }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2025-02-02 14:29:03 +00:00
|
|
|
|
bool PointRefers::isAnonymous() const
|
2024-03-17 07:58:28 +00:00
|
|
|
|
{
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return true;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-02-02 14:29:03 +00:00
|
|
|
|
QString PointRefers::signature() const {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
QString signature = u8"@" + storyRefer() + u8"&" + fragmentRefer();
|
|
|
|
|
return parent()->signature() + signature;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-18 04:44:18 +00:00
|
|
|
|
|
2025-02-02 14:30:47 +00:00
|
|
|
|
PointDefines::PointDefines(std::shared_ptr<const ExprRule> rule_bind)
|
2024-06-18 03:54:36 +00:00
|
|
|
|
: AbstractImpl(rule_bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2025-02-02 14:30:47 +00:00
|
|
|
|
QString PointDefines::name() const { return name_store; }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2025-02-02 14:30:47 +00:00
|
|
|
|
void example_novel::PointDefines::setName(const QString& nm)
|
2024-06-18 04:44:18 +00:00
|
|
|
|
{
|
2024-07-28 08:37:31 +00:00
|
|
|
|
this->name_store = nm;
|
2024-06-18 04:44:18 +00:00
|
|
|
|
}
|
2024-07-28 08:37:31 +00:00
|
|
|
|
|
2025-02-02 14:30:47 +00:00
|
|
|
|
int PointDefines::typeMark() const { return (int)NovelNode::PointDefines; }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2025-02-02 14:30:47 +00:00
|
|
|
|
bool PointDefines::isAnonymous() const
|
2024-03-17 07:58:28 +00:00
|
|
|
|
{
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return false;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-02-02 14:30:47 +00:00
|
|
|
|
QString PointDefines::signature() const { return parent()->signature() + u8"&" + name(); }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-18 04:44:18 +00:00
|
|
|
|
|
2024-07-12 04:53:43 +00:00
|
|
|
|
StoryDefine::StoryDefine(std::shared_ptr<const ExprRule> rule_bind)
|
2024-06-20 13:36:46 +00:00
|
|
|
|
: AbstractImpl(rule_bind), sort_index(0) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-18 04:44:18 +00:00
|
|
|
|
QString StoryDefine::name() const { return name_store; }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-07-28 08:37:31 +00:00
|
|
|
|
void example_novel::StoryDefine::setName(const QString& nm)
|
|
|
|
|
{
|
|
|
|
|
this->name_store = nm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void example_novel::StoryDefine::setSort(int value) {
|
2024-06-20 13:36:46 +00:00
|
|
|
|
sort_index = value;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-18 04:44:18 +00:00
|
|
|
|
int StoryDefine::sort() const { return sort_index; }
|
|
|
|
|
|
2024-03-17 07:58:28 +00:00
|
|
|
|
int StoryDefine::typeMark() const { return (int)NovelNode::StoryDefine; }
|
|
|
|
|
|
2024-06-20 13:36:46 +00:00
|
|
|
|
bool StoryDefine::isAnonymous() const
|
2024-03-17 07:58:28 +00:00
|
|
|
|
{
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return false;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
QString StoryDefine::signature() const { return name(); }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
|
|
|
|
#include "syntax_novel.h"
|
2024-07-12 04:53:43 +00:00
|
|
|
|
Document::Document(std::shared_ptr<const ExprRule> rule_bind)
|
2024-06-18 03:54:36 +00:00
|
|
|
|
: AbstractImpl(rule_bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
|
|
|
|
int Document::typeMark() const { return (int)NovelNode::Document; }
|
|
|
|
|
|
2024-06-20 13:36:46 +00:00
|
|
|
|
bool Document::isAnonymous() const
|
2024-03-17 07:58:28 +00:00
|
|
|
|
{
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return true;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Document::signature() const { return QString(u8"::document<%1>").arg(path()); }
|
|
|
|
|
|
2024-07-12 04:53:43 +00:00
|
|
|
|
AbstractImpl::AbstractImpl(std::shared_ptr<const ExprRule> rule_bind)
|
2024-07-28 08:37:31 +00:00
|
|
|
|
: ExprElement(rule_bind) {
|
|
|
|
|
parent_store.reset();
|
|
|
|
|
}
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
|
|
|
|
QList<std::shared_ptr<const ast_gen::TokenAccess> > AbstractImpl::selfTokens() const {
|
2024-07-28 06:41:54 +00:00
|
|
|
|
auto tokensx = ast_basic::ExprElement::tokens();
|
2024-06-18 03:54:36 +00:00
|
|
|
|
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));
|
|
|
|
|
}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return values;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-20 13:36:46 +00:00
|
|
|
|
std::shared_ptr<const ast_gen::SyntaxElement> AbstractImpl::parent() const
|
2024-03-17 07:58:28 +00:00
|
|
|
|
{
|
2024-06-18 11:55:36 +00:00
|
|
|
|
return this->parent_store.lock();
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-20 13:36:46 +00:00
|
|
|
|
void AbstractImpl::setParent(std::shared_ptr<const ast_gen::SyntaxElement> inst)
|
2024-06-18 03:54:36 +00:00
|
|
|
|
{
|
|
|
|
|
this->parent_store = inst;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
|
|
|
|
// ͨ<><CDA8> SyntaxElement <20>̳<EFBFBD>
|
2024-07-12 21:52:32 +00:00
|
|
|
|
std::shared_ptr<const ast_basic::IExprInst> AbstractImpl::bindExpression() const {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return shared_from_this();
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-20 13:36:46 +00:00
|
|
|
|
QString AbstractImpl::path() const
|
2024-06-18 03:54:36 +00:00
|
|
|
|
{
|
2024-07-28 06:41:54 +00:00
|
|
|
|
return ast_basic::ExprElement::filePath();
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 04:53:43 +00:00
|
|
|
|
VolumeDefine::VolumeDefine(std::shared_ptr<const ExprRule> rule_bind)
|
2024-06-18 03:54:36 +00:00
|
|
|
|
: AbstractImpl(rule_bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-18 04:44:18 +00:00
|
|
|
|
QString VolumeDefine::name() const { return name_store; }
|
|
|
|
|
|
2024-07-28 08:37:31 +00:00
|
|
|
|
void example_novel::VolumeDefine::setName(const QString& nm)
|
2024-06-18 04:44:18 +00:00
|
|
|
|
{
|
2024-07-28 08:37:31 +00:00
|
|
|
|
this->name_store = nm;
|
2024-06-18 04:44:18 +00:00
|
|
|
|
}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
|
|
|
|
int VolumeDefine::typeMark() const { return (int)NovelNode::VolumeDefine; }
|
|
|
|
|
|
2024-06-20 13:36:46 +00:00
|
|
|
|
bool VolumeDefine::isAnonymous() const
|
2024-03-17 07:58:28 +00:00
|
|
|
|
{
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return false;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString VolumeDefine::signature() const { return name(); }
|
|
|
|
|
|
2024-07-12 04:53:43 +00:00
|
|
|
|
ArticleDefine::ArticleDefine(std::shared_ptr<const ExprRule> rule_bind)
|
2024-06-18 03:54:36 +00:00
|
|
|
|
: AbstractImpl(rule_bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-18 04:44:18 +00:00
|
|
|
|
QString ArticleDefine::name() const { return name_store; }
|
|
|
|
|
|
2024-07-28 08:37:31 +00:00
|
|
|
|
void example_novel::ArticleDefine::setName(const QString& nm)
|
2024-06-18 04:44:18 +00:00
|
|
|
|
{
|
2024-07-28 08:37:31 +00:00
|
|
|
|
this->name_store = nm;
|
2024-06-18 04:44:18 +00:00
|
|
|
|
}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
|
|
|
|
int ArticleDefine::typeMark() const { return (int)NovelNode::ArticleDefine; }
|
|
|
|
|
|
2024-06-20 13:36:46 +00:00
|
|
|
|
bool ArticleDefine::isAnonymous() const
|
2024-03-17 07:58:28 +00:00
|
|
|
|
{
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return false;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ArticleDefine::signature() const { return parent()->signature() + u8"&" + name(); }
|
2024-06-20 13:36:46 +00:00
|
|
|
|
|
2024-07-12 04:53:43 +00:00
|
|
|
|
RankDeclare::RankDeclare(std::shared_ptr<const ExprRule> rule)
|
2024-07-28 08:37:31 +00:00
|
|
|
|
: AbstractImpl(rule)
|
2024-06-20 13:36:46 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int example_novel::RankDeclare::rankNumber() const
|
|
|
|
|
{
|
|
|
|
|
return page_rank;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-28 08:37:31 +00:00
|
|
|
|
void example_novel::RankDeclare::setRank(int nums)
|
|
|
|
|
{
|
|
|
|
|
this->page_rank = nums;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-20 13:36:46 +00:00
|
|
|
|
int RankDeclare::typeMark() const
|
|
|
|
|
{
|
|
|
|
|
return (int)NovelNode::RankDeclaration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool RankDeclare::isAnonymous() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString RankDeclare::signature() const
|
|
|
|
|
{
|
|
|
|
|
return u8"::rank";
|
|
|
|
|
}
|