nothing
This commit is contained in:
parent
fea231dec8
commit
823f8d08ae
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
#include "ast_gen.h"
|
#include "ast_gen.h"
|
||||||
|
|
||||||
namespace example_novel
|
namespace example_novel {
|
||||||
{
|
|
||||||
enum class NovelNode {
|
enum class NovelNode {
|
||||||
GlobalElement = 0,
|
GlobalElement = 0,
|
||||||
TextSection = 1,
|
TextSection = 1,
|
||||||
|
@ -50,10 +49,10 @@ namespace example_novel
|
||||||
FragmentRefers(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
|
FragmentRefers(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
|
||||||
|
|
||||||
QString storyRefer() const;
|
QString storyRefer() const;
|
||||||
void setStoryRefer(const QString &refer);
|
void setStoryRefer(const QString& refer);
|
||||||
|
|
||||||
QString fragmentRefer() const;
|
QString fragmentRefer() const;
|
||||||
void setFragmentRefer(const QString &refer);
|
void setFragmentRefer(const QString& refer);
|
||||||
|
|
||||||
QString referSignature() const;
|
QString referSignature() const;
|
||||||
|
|
||||||
|
@ -72,7 +71,7 @@ namespace example_novel
|
||||||
FragmentDefine(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
|
FragmentDefine(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &nm);
|
void setName(const QString& nm);
|
||||||
|
|
||||||
// SyntaxElement interface
|
// SyntaxElement interface
|
||||||
public:
|
public:
|
||||||
|
@ -89,7 +88,7 @@ namespace example_novel
|
||||||
ArticleDefine(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
|
ArticleDefine(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &nm);
|
void setName(const QString& nm);
|
||||||
|
|
||||||
// SyntaxElement interface
|
// SyntaxElement interface
|
||||||
public:
|
public:
|
||||||
|
@ -106,7 +105,7 @@ namespace example_novel
|
||||||
VolumeDefine(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
|
VolumeDefine(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &nm);
|
void setName(const QString& nm);
|
||||||
|
|
||||||
// SyntaxElement interface
|
// SyntaxElement interface
|
||||||
public:
|
public:
|
||||||
|
@ -123,7 +122,7 @@ namespace example_novel
|
||||||
StoryDefine(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
|
StoryDefine(std::shared_ptr<const lib_syntax::ExprRule> rule_bind);
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &nm);
|
void setName(const QString& nm);
|
||||||
|
|
||||||
void setSort(int value);
|
void setSort(int value);
|
||||||
int sort() const;
|
int sort() const;
|
||||||
|
@ -170,7 +169,7 @@ namespace lib_syntax {
|
||||||
template<> class ElementRule<example_novel::TextSection> : public ExprRule {
|
template<> class ElementRule<example_novel::TextSection> : public ExprRule {
|
||||||
public:
|
public:
|
||||||
ElementRule<example_novel::TextSection>(const QString& rule_name, int expr_mark)
|
ElementRule<example_novel::TextSection>(const QString& rule_name, int expr_mark)
|
||||||
:ExprRule(rule_name, expr_mark) {}
|
:ExprRule(rule_name, expr_mark) { }
|
||||||
|
|
||||||
// ͨ¹ý ExprRule ¼Ì³Ð
|
// ͨ¹ý ExprRule ¼Ì³Ð
|
||||||
virtual std::shared_ptr<ast_basic::IExprInst> newEmptyInstance() const {
|
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>>
|
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 {
|
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();
|
std::shared_ptr<ast_basic::IExprInst> elm_ast = this->newEmptyInstance();
|
||||||
auto text_present = this->token_present();
|
auto text_present = this->token_present();
|
||||||
|
|
||||||
|
@ -199,35 +199,36 @@ namespace lib_syntax {
|
||||||
rt_inst->popExprInst();
|
rt_inst->popExprInst();
|
||||||
rt_inst->popExprRule();
|
rt_inst->popExprRule();
|
||||||
break;
|
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();
|
if (!std::dynamic_pointer_cast<example_novel::Document>(elm_ast)) {
|
||||||
rt_inst->clearErrors(rt_inst->currentFile(), start_pos);
|
auto start_pos = tokens_decl.first()->position();
|
||||||
}
|
rt_inst->clearErrors(rt_inst->currentFile(), start_pos);
|
||||||
|
}
|
||||||
|
|
||||||
rt_inst->popExprInst();
|
rt_inst->popExprInst();
|
||||||
rt_inst->popExprRule();
|
rt_inst->popExprRule();
|
||||||
while (tokens_decl.size()) {
|
while (tokens_decl.size()) {
|
||||||
auto text_paragraph = this->newEmptyInstance();
|
auto text_paragraph = this->newEmptyInstance();
|
||||||
int row_n = tokens_decl.first()->row();
|
int row_n = tokens_decl.first()->row();
|
||||||
|
|
||||||
for (int idx = 0; idx < tokens_decl.size(); ++idx) {
|
for (int idx = 0; idx < tokens_decl.size(); ++idx) {
|
||||||
auto target_token = tokens_decl.at(idx);
|
auto target_token = tokens_decl.at(idx);
|
||||||
if (target_token->row() == row_n) {
|
if (target_token->row() == row_n) {
|
||||||
text_paragraph->addToken(target_token);
|
text_paragraph->addToken(target_token);
|
||||||
tokens_decl.removeAt(idx--);
|
tokens_decl.removeAt(idx--);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rt_inst->currentExprInst()) {
|
||||||
|
rt_inst->currentExprInst()->addChild(text_paragraph);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rt_inst->appendDocInst(text_paragraph);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rt_inst->currentExprInst()) {
|
}break;
|
||||||
rt_inst->currentExprInst()->addChild(text_paragraph);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
rt_inst->appendDocInst(text_paragraph);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue