This commit is contained in:
codeboss 2025-02-02 22:06:49 +08:00
parent fea231dec8
commit 823f8d08ae
1 changed files with 34 additions and 33 deletions

View File

@ -2,8 +2,7 @@
#include "ast_gen.h"
namespace example_novel
{
namespace example_novel {
enum class NovelNode {
GlobalElement = 0,
TextSection = 1,
@ -50,10 +49,10 @@ namespace example_novel
FragmentRefers(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
QString storyRefer() const;
void setStoryRefer(const QString &refer);
void setStoryRefer(const QString& refer);
QString fragmentRefer() const;
void setFragmentRefer(const QString &refer);
void setFragmentRefer(const QString& refer);
QString referSignature() const;
@ -72,7 +71,7 @@ namespace example_novel
FragmentDefine(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
QString name() const;
void setName(const QString &nm);
void setName(const QString& nm);
// SyntaxElement interface
public:
@ -89,7 +88,7 @@ namespace example_novel
ArticleDefine(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
QString name() const;
void setName(const QString &nm);
void setName(const QString& nm);
// SyntaxElement interface
public:
@ -106,7 +105,7 @@ namespace example_novel
VolumeDefine(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
QString name() const;
void setName(const QString &nm);
void setName(const QString& nm);
// SyntaxElement interface
public:
@ -123,7 +122,7 @@ namespace example_novel
StoryDefine(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
QString name() const;
void setName(const QString &nm);
void setName(const QString& nm);
void setSort(int value);
int sort() const;
@ -170,7 +169,7 @@ namespace lib_syntax {
template<> class ElementRule<example_novel::TextSection> : public ExprRule {
public:
ElementRule<example_novel::TextSection>(const QString& rule_name, int expr_mark)
:ExprRule(rule_name, expr_mark) {}
:ExprRule(rule_name, expr_mark) { }
// ͨ¹ý ExprRule ¼Ì³Ð
virtual std::shared_ptr<ast_basic::IExprInst> newEmptyInstance() const {
@ -184,6 +183,7 @@ namespace lib_syntax {
virtual std::tuple<IBasicRule::MatchResult, std::shared_ptr<const lib_words::IWordBase>>
parse(std::shared_ptr<IContext> rt_inst, std::shared_ptr<const lib_words::IWordBase> head) const override {
std::shared_ptr<ast_basic::IExprInst> elm_ast = this->newEmptyInstance();
auto text_present = this->token_present();
@ -199,7 +199,8 @@ namespace lib_syntax {
rt_inst->popExprInst();
rt_inst->popExprRule();
break;
case IBasicRule::MatchResult::Success: {
case IBasicRule::MatchResult::Success:
{
if (!std::dynamic_pointer_cast<example_novel::Document>(elm_ast)) {
auto start_pos = tokens_decl.first()->position();
rt_inst->clearErrors(rt_inst->currentFile(), start_pos);