Compare commits
3 Commits
90104e0e9e
...
86ecdc2c5e
Author | SHA1 | Date |
---|---|---|
|
86ecdc2c5e | |
|
4d3d19c6a7 | |
|
97763d28e8 |
|
@ -23,7 +23,7 @@ std::tuple<IBasicRule::MatchResult, std::shared_ptr<const IWordBase>> TokenMatch
|
|||
}
|
||||
else {
|
||||
rt_inst->appendParseErrors(rt_inst->currentFile(), head->position(),
|
||||
QString(u8"Syntax[0x00001]语法匹配错误,无法识别\"%1\"<row:%2,col:%3>(应该为:%4)\n\t目标语法:'%5'。\n")
|
||||
QString(u8"Syntax[0x00001]语法匹配错误,无法识别\"%1\"<row:%2,col:%3>(应该为:%4)\n\t目标语法:%5。\n")
|
||||
.arg(head->content()).arg(head->row()).arg(head->column()).arg(this->define_peer->reviseWords())
|
||||
.arg(rt_inst->currentExprRule()->token_present()));
|
||||
return std::make_tuple(IBasicRule::MatchResult::Part, head);
|
||||
|
@ -129,18 +129,6 @@ Any::Any(const QList<std::shared_ptr<const IBasicRule>> mbrs) : mbrs_store(mbrs)
|
|||
|
||||
QList<std::shared_ptr<const IBasicRule>> Any::children() const { return mbrs_store; }
|
||||
|
||||
class words_span {
|
||||
public:
|
||||
int row_span, column_span;
|
||||
words_span(int rspan, int cspan) :row_span(rspan), column_span(cspan) {}
|
||||
bool operator>(const words_span& other) {
|
||||
if (row_span > other.row_span)
|
||||
return true;
|
||||
if (row_span == other.row_span)
|
||||
return column_span > other.column_span;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
std::tuple<IBasicRule::MatchResult, std::shared_ptr<const IWordBase>> Any::parse(std::shared_ptr<IContext> rt_inst, std::shared_ptr<const IWordBase> head) const {
|
||||
std::tuple<std::shared_ptr<const IBasicRule>, uint64_t> temp_result = std::make_tuple(nullptr, 0);
|
||||
auto rule_present = this->token_present();
|
||||
|
|
|
@ -12,6 +12,7 @@ auto leftb = std::make_shared<LeftBracket>(); // {
|
|||
auto rightb = std::make_shared<RightBracket>(); // }
|
||||
auto refers = std::make_shared<ReferMark>(); // @
|
||||
auto declare = std::make_shared<DeclareSymbo>(); // #
|
||||
auto split_mark = std::make_shared<Split>(); // &
|
||||
|
||||
auto rank_key = std::make_shared<Keywords>(u8"排序", 0xAEu); // 排序
|
||||
auto story_key = std::make_shared<Keywords>(u8"故事", 0xAAu); // 故事
|
||||
|
@ -19,9 +20,8 @@ auto numbers = std::make_shared<Numbers>(); // [0-9
|
|||
auto frag_key = std::make_shared<Keywords>(u8"情节", 0xABu); // 情节
|
||||
auto volume_key = std::make_shared<Keywords>(u8"分卷", 0xACu); // 分卷
|
||||
auto article_key = std::make_shared<Keywords>(u8"章节", 0xADu); // 章节
|
||||
auto split_mark = std::make_shared<Split>(); // &
|
||||
auto vtext = std::make_shared<VTextSection>(); // ^([^\\{\\}\\n@&]+)
|
||||
auto name_text = std::make_shared<NameSection>(); // ^([^:\\{\\}\\n@&][^\\{\\}\\n@&]*)
|
||||
auto vtext = std::make_shared<VTextSection>(); // ^([^\\{\\}\@&]+)
|
||||
auto name_text = std::make_shared<NameSection>(); // ^([^\\{\\}@&]+)
|
||||
|
||||
|
||||
|
||||
|
@ -35,32 +35,33 @@ auto name_text = std::make_shared<NameSection>(); // ^
|
|||
#define OptMulR(rule) std::make_shared<const Rept>(rule, 0, INT_MAX)
|
||||
// multi+
|
||||
#define MultiR(rule) std::make_shared<const Rept>(rule, 1, INT_MAX)
|
||||
// opt?
|
||||
#define OptR(rule) std::make_shared<const Rept>(rule, 0, 1)
|
||||
|
||||
|
||||
|
||||
auto decl_comp = std::make_shared<const Any>(Rules{ MR(numbers), MR(vtext), MR(name_text), MR(split_mark) });
|
||||
auto decl_expr = ElementRule<TextSection>(u8"decl_section", (int)NovelExprs::DESC_SECTION).reloadRule(
|
||||
MultiR(decl_comp));
|
||||
MultiR(std::make_shared<const Any>(Rules{ MR(numbers), MR(vtext), MR(refers), MR(split_mark)}))
|
||||
);
|
||||
|
||||
auto fragment_decl = ElementRule<FragmentDefine>(u8"fragment_define", (int)NovelExprs::FRAG_DEFINES).reloadRule(
|
||||
std::make_shared<const Seqs>(
|
||||
Rules{ MR(leftb), MR(frag_key), MR(name_text) } <<
|
||||
OptMulR(decl_expr) <<
|
||||
std::make_shared<const Seqs>(Rules{
|
||||
MR(leftb), MR(frag_key), MR(name_text) } <<
|
||||
OptR(decl_expr) <<
|
||||
MR(rightb)
|
||||
));
|
||||
|
||||
auto fragment_refer = ElementRule<FragmentRefers>(u8"fragment_refer", (int)NovelExprs::FRAG_REFERS).reloadRule(
|
||||
std::make_shared<const Seqs>(
|
||||
Rules{ MR(leftb), MR(refers), MR(frag_key), MR(name_text), MR(split_mark), MR(name_text) } <<
|
||||
OptMulR(decl_expr) <<
|
||||
std::make_shared<const Seqs>(Rules{
|
||||
MR(leftb), MR(refers), MR(frag_key), MR(name_text), MR(split_mark), MR(name_text) } <<
|
||||
OptR(decl_expr) <<
|
||||
MR(rightb)
|
||||
));
|
||||
|
||||
auto fragment_comp = std::make_shared<const Any>(Rules{ fragment_decl, fragment_refer, decl_expr });
|
||||
auto story_define = ElementRule<StoryDefine>(u8"story_define", (int)NovelExprs::STORY_DEFINES).reloadRule(
|
||||
std::make_shared<const Seqs>(
|
||||
Rules{ MR(leftb), MR(story_key), MR(name_text) } <<
|
||||
OptMulR(fragment_comp) <<
|
||||
std::make_shared<const Seqs>(Rules{
|
||||
MR(leftb), MR(story_key), MR(name_text) } <<
|
||||
OptMulR(std::make_shared<const Any>(Rules{ fragment_decl, fragment_refer, decl_expr })) <<
|
||||
MR(rightb)
|
||||
));
|
||||
// ===================================================================
|
||||
|
@ -79,8 +80,8 @@ auto volume_decl = ElementRule<VolumeDefine>(u8"volume_define", (int)NovelExprs:
|
|||
));
|
||||
|
||||
auto rank_define = ElementRule<RankDeclare>(u8"rank_define", (int)NovelNode::RankDeclaration).reloadRule(
|
||||
std::make_shared<const Seqs>(
|
||||
Rules{ MR(declare), MR(rank_key), MR(numbers) }
|
||||
std::make_shared<const Seqs>(Rules{
|
||||
MR(declare), MR(rank_key), MR(numbers) }
|
||||
));
|
||||
|
||||
auto document_define = ElementRule<Document>(u8"decls-doc", (int)NovelExprs::DOC_DEFINES).reloadRule(
|
||||
|
|
|
@ -26,7 +26,7 @@ std::shared_ptr<const IWordBase> lib_token::TokenContent::nextWord() const
|
|||
|
||||
std::shared_ptr<const ITokenDefine> TokenContent::define() const { return this->type_def; }
|
||||
|
||||
QString LeftBracket::reviseWords() const { return u8"{"; }
|
||||
QString LeftBracket::reviseWords() const { return u8"'{'"; }
|
||||
|
||||
int LeftBracket::typeMark() const
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ LeftBracket::analysis(std::shared_ptr<const IWordBase> content) const {
|
|||
return std::make_tuple(token_inst, nullptr);
|
||||
}
|
||||
|
||||
QString RightBracket::reviseWords() const { return u8"}"; }
|
||||
QString RightBracket::reviseWords() const { return u8"'}'"; }
|
||||
|
||||
int RightBracket::typeMark() const
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ int RightBracket::typeMark() const
|
|||
|
||||
QString RightBracket::regex() const { return u8"}"; }
|
||||
|
||||
QString ReferMark::reviseWords() const { return u8"@"; }
|
||||
QString ReferMark::reviseWords() const { return u8"'@'"; }
|
||||
|
||||
int ReferMark::typeMark() const
|
||||
{
|
||||
|
@ -73,7 +73,7 @@ QString ReferMark::regex() const { return u8"@"; }
|
|||
|
||||
Keywords::Keywords(const QString& val, uint type_code) : means_store(val), type_code(type_code) {}
|
||||
|
||||
QString Keywords::reviseWords() const { return means_store; }
|
||||
QString Keywords::reviseWords() const { return "'"+means_store+"'"; }
|
||||
|
||||
int Keywords::typeMark() const
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ int VTextSection::typeMark() const
|
|||
return 0x09000000;
|
||||
}
|
||||
|
||||
QString VTextSection::regex() const { return u8"^([^\\{\\}\\n@&]+)"; }
|
||||
QString VTextSection::regex() const { return u8"^([^\\{\\}@&]+)"; }
|
||||
|
||||
std::tuple<std::shared_ptr<const IToken>, std::shared_ptr<const IWordBase>>
|
||||
VTextSection::analysis(std::shared_ptr<const IWordBase> content) const {
|
||||
|
@ -144,7 +144,7 @@ VTextSection::analysis(std::shared_ptr<const IWordBase> content) const {
|
|||
return std::make_tuple(tinst, nullptr);
|
||||
}
|
||||
|
||||
QString Split::reviseWords() const { return u8"&"; }
|
||||
QString Split::reviseWords() const { return u8"'&'"; }
|
||||
|
||||
int Split::typeMark() const
|
||||
{
|
||||
|
@ -160,7 +160,7 @@ int NameSection::typeMark() const
|
|||
return 0x08000000;
|
||||
}
|
||||
|
||||
QString NameSection::regex() const { return u8"^([^:\\{\\}\\n@&][^\\{\\}\\n@&]*)"; }
|
||||
QString NameSection::regex() const { return u8"^([^\\{\\}@&]+)"; }
|
||||
|
||||
std::tuple<std::shared_ptr<const IToken>, std::shared_ptr<const IWordBase> > NameSection::analysis(std::shared_ptr<const IWordBase> content) const
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ std::tuple<std::shared_ptr<const IToken>, std::shared_ptr<const IWordBase> > Nam
|
|||
}
|
||||
|
||||
QString DeclareSymbo::reviseWords() const {
|
||||
return u8"ÉùÃ÷·û";
|
||||
return u8"'ÉùÃ÷·û'";
|
||||
}
|
||||
|
||||
int DeclareSymbo::typeMark() const
|
||||
|
|
Loading…
Reference in New Issue