2024-03-17 07:58:28 +00:00
|
|
|
|
#include "ast_novel.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace example_novel;
|
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
TextSection::TextSection(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
|
|
|
|
: AbstractImpl(rule_bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
|
|
|
|
QString example_novel::TextSection::content() const
|
|
|
|
|
{
|
2024-06-18 03:54:36 +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 example_novel::TextSection::isAnonymous() const
|
|
|
|
|
{
|
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"; }
|
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
FragmentRefers::FragmentRefers(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
|
|
|
|
: AbstractImpl(rule_bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
QString FragmentRefers::storyRefer() const { return selfTokens()[5]->token()->content(); }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
QString FragmentRefers::fragmentRefer() const { return selfTokens()[3]->token()->content(); }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-03-31 05:59:17 +00:00
|
|
|
|
QString FragmentRefers::referSignature() const {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return storyRefer() + u8"&" + fragmentRefer();
|
2024-03-31 05:59:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 07:58:28 +00:00
|
|
|
|
int FragmentRefers::typeMark() const { return (int)NovelNode::FragmentRefer; }
|
|
|
|
|
|
|
|
|
|
bool example_novel::FragmentRefers::isAnonymous() const
|
|
|
|
|
{
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return true;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString FragmentRefers::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 03:54:36 +00:00
|
|
|
|
FragmentDefine::FragmentDefine(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
|
|
|
|
: AbstractImpl(rule_bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
QString FragmentDefine::name() const { return selfTokens()[2]->token()->content(); }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
|
|
|
|
int FragmentDefine::typeMark() const { return (int)NovelNode::FragmentDefine; }
|
|
|
|
|
|
|
|
|
|
bool example_novel::FragmentDefine::isAnonymous() const
|
|
|
|
|
{
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return false;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString FragmentDefine::signature() const { return parent()->signature() + u8"&" + name(); }
|
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
StoryDefine::StoryDefine(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
|
|
|
|
: AbstractImpl(rule_bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
QString StoryDefine::name() const { return selfTokens()[3]->token()->content(); }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
int StoryDefine::sort() const { return selfTokens()[2]->token()->content().toInt(); }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
|
|
|
|
int StoryDefine::typeMark() const { return (int)NovelNode::StoryDefine; }
|
|
|
|
|
|
|
|
|
|
bool example_novel::StoryDefine::isAnonymous() const
|
|
|
|
|
{
|
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-06-18 03:54:36 +00:00
|
|
|
|
Document::Document(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
|
|
|
|
: AbstractImpl(rule_bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
|
|
|
|
int Document::typeMark() const { return (int)NovelNode::Document; }
|
|
|
|
|
|
|
|
|
|
bool example_novel::Document::isAnonymous() const
|
|
|
|
|
{
|
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-06-18 03:54:36 +00:00
|
|
|
|
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));
|
|
|
|
|
}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<const ast_gen::SyntaxElement> example_novel::AbstractImpl::parent() const
|
2024-03-17 07:58:28 +00:00
|
|
|
|
{
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return this->parent_store;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
void example_novel::AbstractImpl::setParent(std::shared_ptr<const ast_gen::SyntaxElement> inst)
|
|
|
|
|
{
|
|
|
|
|
this->parent_store = inst;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
|
|
|
|
// ͨ<><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();
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
VolumeDefine::VolumeDefine(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
|
|
|
|
: AbstractImpl(rule_bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
QString VolumeDefine::name() const { return selfTokens()[2]->token()->content(); }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
|
|
|
|
int VolumeDefine::typeMark() const { return (int)NovelNode::VolumeDefine; }
|
|
|
|
|
|
|
|
|
|
bool example_novel::VolumeDefine::isAnonymous() const
|
|
|
|
|
{
|
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-06-18 03:54:36 +00:00
|
|
|
|
ArticleDefine::ArticleDefine(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
|
|
|
|
|
: AbstractImpl(rule_bind) {}
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
2024-06-18 03:54:36 +00:00
|
|
|
|
QString ArticleDefine::name() const { return selfTokens()[2]->token()->content(); }
|
2024-03-17 07:58:28 +00:00
|
|
|
|
|
|
|
|
|
int ArticleDefine::typeMark() const { return (int)NovelNode::ArticleDefine; }
|
|
|
|
|
|
|
|
|
|
bool example_novel::ArticleDefine::isAnonymous() const
|
|
|
|
|
{
|
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(); }
|