WsParser_VS/libSyntax/ast_novel.cpp

233 lines
5.2 KiB
C++
Raw Normal View History

2024-03-17 07:58:28 +00:00
#include "ast_novel.h"
using namespace example_novel;
using namespace lib_syntax;
2024-03-17 07:58:28 +00:00
TextSection::TextSection(std::shared_ptr<const ExprRule> rule_bind)
: AbstractImpl(rule_bind) {}
2024-03-17 07:58:28 +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; }
bool TextSection::isAnonymous() const
2024-03-17 07:58:28 +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)
: 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-04 14:26:34 +00:00
QString PointRefers::pointRefer() const { return point_ref; }
2024-03-17 07:58:28 +00:00
2025-02-04 14:26:34 +00:00
void example_novel::PointRefers::setPointRefer(const QString& refer) {
this->point_ref = refer;
}
2024-07-28 08:37:31 +00:00
2025-02-02 14:29:03 +00:00
QString PointRefers::referSignature() const {
2025-02-04 14:26:34 +00:00
return storyRefer() + u8"&" + sliceRefer() + u8"&" + pointRefer();
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
{
return true;
2024-03-17 07:58:28 +00:00
}
2025-02-02 14:29:03 +00:00
QString PointRefers::signature() const {
QString signature = u8"@" + storyRefer() + u8"&" + fragmentRefer();
return parent()->signature() + signature;
2024-03-17 07:58:28 +00:00
}
2025-02-02 14:30:47 +00:00
PointDefines::PointDefines(std::shared_ptr<const ExprRule> rule_bind)
: 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-07-28 08:37:31 +00:00
this->name_store = nm;
}
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
{
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
StoryDefine::StoryDefine(std::shared_ptr<const ExprRule> rule_bind)
: AbstractImpl(rule_bind), sort_index(0) {}
2024-03-17 07:58:28 +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) {
sort_index = value;
}
int StoryDefine::sort() const { return sort_index; }
2024-03-17 07:58:28 +00:00
int StoryDefine::typeMark() const { return (int)NovelNode::StoryDefine; }
bool StoryDefine::isAnonymous() const
2024-03-17 07:58:28 +00:00
{
return false;
2024-03-17 07:58:28 +00:00
}
QString StoryDefine::signature() const { return name(); }
2024-03-17 07:58:28 +00:00
#include "syntax_novel.h"
Document::Document(std::shared_ptr<const ExprRule> rule_bind)
: AbstractImpl(rule_bind) {}
2024-03-17 07:58:28 +00:00
int Document::typeMark() const { return (int)NovelNode::Document; }
bool Document::isAnonymous() const
2024-03-17 07:58:28 +00:00
{
return true;
2024-03-17 07:58:28 +00:00
}
QString Document::signature() const { return QString(u8"::document<%1>").arg(path()); }
AbstractImpl::AbstractImpl(std::shared_ptr<const ExprRule> rule_bind)
2024-07-28 08:37:31 +00:00
: ExprElement(rule_bind) {
parent_store.reset();
}
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();
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
return values;
}
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
}
void AbstractImpl::setParent(std::shared_ptr<const ast_gen::SyntaxElement> inst)
{
this->parent_store = inst;
2024-03-17 07:58:28 +00:00
}
// ͨ<><CDA8> SyntaxElement <20>̳<EFBFBD>
2024-07-12 21:52:32 +00:00
std::shared_ptr<const ast_basic::IExprInst> AbstractImpl::bindExpression() const {
return shared_from_this();
}
QString AbstractImpl::path() const
{
2024-07-28 06:41:54 +00:00
return ast_basic::ExprElement::filePath();
2024-03-17 07:58:28 +00:00
}
VolumeDefine::VolumeDefine(std::shared_ptr<const ExprRule> rule_bind)
: AbstractImpl(rule_bind) {}
2024-03-17 07:58:28 +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-07-28 08:37:31 +00:00
this->name_store = nm;
}
2024-03-17 07:58:28 +00:00
int VolumeDefine::typeMark() const { return (int)NovelNode::VolumeDefine; }
bool VolumeDefine::isAnonymous() const
2024-03-17 07:58:28 +00:00
{
return false;
2024-03-17 07:58:28 +00:00
}
QString VolumeDefine::signature() const { return name(); }
ArticleDefine::ArticleDefine(std::shared_ptr<const ExprRule> rule_bind)
: AbstractImpl(rule_bind) {}
2024-03-17 07:58:28 +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-07-28 08:37:31 +00:00
this->name_store = nm;
}
2024-03-17 07:58:28 +00:00
int ArticleDefine::typeMark() const { return (int)NovelNode::ArticleDefine; }
bool ArticleDefine::isAnonymous() const
2024-03-17 07:58:28 +00:00
{
return false;
2024-03-17 07:58:28 +00:00
}
QString ArticleDefine::signature() const { return parent()->signature() + u8"&" + name(); }
RankDeclare::RankDeclare(std::shared_ptr<const ExprRule> rule)
2024-07-28 08:37:31 +00:00
: AbstractImpl(rule)
{
}
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;
}
int RankDeclare::typeMark() const
{
return (int)NovelNode::RankDeclaration;
}
bool RankDeclare::isAnonymous() const
{
return true;
}
QString RankDeclare::signature() const
{
return u8"::rank";
}
2025-02-04 14:26:34 +00:00
int example_novel::FragmentSlice::typeMark() const {
return 0;
}
bool example_novel::FragmentSlice::isAnonymous() const {
return false;
}
QString example_novel::FragmentSlice::signature() const {
return QString();
}