framework-update
This commit is contained in:
parent
c277af9c36
commit
a92b4cacc1
|
@ -52,42 +52,45 @@ QList<ParseFork> TokenMatch::parse(const ParseFork& context) const
|
||||||
}
|
}
|
||||||
// 缺一个
|
// 缺一个
|
||||||
ParseFork absence_fork(context);
|
ParseFork absence_fork(context);
|
||||||
result_list << absence_fork;
|
|
||||||
absence_fork.error_messages << QString(u8"Syntax[0x0002]缺失Token('%1'<row:%2,col:%3>)。")
|
absence_fork.error_messages << QString(u8"Syntax[0x0002]缺失Token('%1'<row:%2,col:%3>)。")
|
||||||
.arg(this->token_present()).arg(head->row()).arg(head->column());
|
.arg(this->token_present()).arg(head->row()).arg(head->column());
|
||||||
absence_fork.next = head;
|
absence_fork.next = head;
|
||||||
absence_fork.occurs = ErrDeals::Absence;
|
absence_fork.occurs = ErrDeals::Absence;
|
||||||
|
result_list << absence_fork;
|
||||||
|
|
||||||
// 错一个
|
// 错一个
|
||||||
ParseFork replace_fork(context);
|
ParseFork replace_fork(context);
|
||||||
result_list << replace_fork;
|
|
||||||
replace_fork.error_messages << QString(u8"Syntax[0x0003]纠正Token('%1'<row:%2,col:%3>,应该为'%4')。")
|
replace_fork.error_messages << QString(u8"Syntax[0x0003]纠正Token('%1'<row:%2,col:%3>,应该为'%4')。")
|
||||||
.arg(head->content()).arg(head->row()).arg(head->column()).arg(this->token_present());
|
.arg(head->content()).arg(head->row()).arg(head->column()).arg(this->token_present());
|
||||||
replace_fork.next = head->nextWord();
|
replace_fork.next = head->nextWord();
|
||||||
replace_fork.occurs = ErrDeals::Replace;
|
replace_fork.occurs = ErrDeals::Replace;
|
||||||
|
result_list << replace_fork;
|
||||||
|
|
||||||
// 多一个
|
// 多一个
|
||||||
auto temp_head = head->nextWord();
|
auto temp_head = head->nextWord();
|
||||||
auto match_result = define_peer->analysis(temp_head);
|
if(temp_head){
|
||||||
if (get<0>(match_result)) {
|
auto match_result = define_peer->analysis(temp_head);
|
||||||
ParseFork surplus_fork(context);
|
if (get<0>(match_result)) {
|
||||||
result_list << surplus_fork;
|
ParseFork surplus_fork(context);
|
||||||
surplus_fork.error_messages << QString(u8"Syntax[0x0004]·¢ÏÖÈßÓàToken£¨'%1'<row:%2,col:%3>£©¡£")
|
surplus_fork.error_messages << QString(u8"Syntax[0x0004]·¢ÏÖÈßÓàToken£¨'%1'<row:%2,col:%3>£©¡£")
|
||||||
.arg(head->content()).arg(head->row()).arg(head->column());
|
.arg(head->content()).arg(head->row()).arg(head->column());
|
||||||
surplus_fork.occurs = ErrDeals::Surplus;
|
surplus_fork.occurs = ErrDeals::Surplus;
|
||||||
surplus_fork.tokens_list << get<0>(match_result);
|
surplus_fork.tokens_list << get<0>(match_result);
|
||||||
|
|
||||||
if (get<1>(match_result))
|
if (get<1>(match_result))
|
||||||
surplus_fork.next = make_shared<WordImpl>(get<1>(match_result), temp_head->nextWord());
|
surplus_fork.next = make_shared<WordImpl>(get<1>(match_result), temp_head->nextWord());
|
||||||
else
|
else
|
||||||
surplus_fork.next = temp_head->nextWord();
|
surplus_fork.next = temp_head->nextWord();
|
||||||
|
|
||||||
|
result_list << surplus_fork;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result_list;
|
return result_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TokenMatch::token_present() const {
|
QString TokenMatch::token_present() const {
|
||||||
return QString(u8"%1 ").arg(this->define_peer->reviseWords());
|
return QString(u8"%1").arg(this->define_peer->reviseWords());
|
||||||
}
|
}
|
||||||
|
|
||||||
Rept::Rept(shared_ptr<const IBasicRule> rule, int min, int max) : rule_peer(rule), min_match(min), max_match(max) {}
|
Rept::Rept(shared_ptr<const IBasicRule> rule, int min, int max) : rule_peer(rule), min_match(min), max_match(max) {}
|
||||||
|
@ -191,6 +194,12 @@ QList<ParseFork> Rept::parse(const ParseFork& context) const {
|
||||||
|
|
||||||
QString Rept::token_present() const
|
QString Rept::token_present() const
|
||||||
{
|
{
|
||||||
|
if (min_match == 0 && max_match == INT_MAX)
|
||||||
|
return u8"(" + this->rule_peer->token_present() + QString(u8")*");
|
||||||
|
|
||||||
|
if (min_match == 1 && max_match == INT_MAX)
|
||||||
|
return u8"(" + this->rule_peer->token_present() + QString(u8")+");
|
||||||
|
|
||||||
return u8"(" + this->rule_peer->token_present() + QString(u8"){%1, %2}").arg(min_match).arg(max_match);
|
return u8"(" + this->rule_peer->token_present() + QString(u8"){%1, %2}").arg(min_match).arg(max_match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,8 +242,8 @@ QString Seqs::token_present() const
|
||||||
{
|
{
|
||||||
QString content;
|
QString content;
|
||||||
for (auto& it : children())
|
for (auto& it : children())
|
||||||
content += it->token_present();
|
content += it->token_present() + u8" ";
|
||||||
return content;
|
return content.mid(0, content.size() -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -247,6 +256,7 @@ QList<ParseFork> Any::parse(const ParseFork& context) const {
|
||||||
QList<ParseFork> temp_results;
|
QList<ParseFork> temp_results;
|
||||||
|
|
||||||
for (auto& fork : mbrs_store) {
|
for (auto& fork : mbrs_store) {
|
||||||
|
auto fork_present = fork->token_present();
|
||||||
auto result_forks = fork->parse(context);
|
auto result_forks = fork->parse(context);
|
||||||
for (auto rst_fork : result_forks) {
|
for (auto rst_fork : result_forks) {
|
||||||
switch (rst_fork.occurs) {
|
switch (rst_fork.occurs) {
|
||||||
|
|
|
@ -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; }
|
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
|
int LeftBracket::typeMark() const
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ LeftBracket::analysis(std::shared_ptr<const IWordBase> content) const {
|
||||||
return std::make_tuple(token_inst, nullptr);
|
return std::make_tuple(token_inst, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RightBracket::reviseWords() const { return u8"}"; }
|
QString RightBracket::reviseWords() const { return u8"'}'"; }
|
||||||
|
|
||||||
int RightBracket::typeMark() const
|
int RightBracket::typeMark() const
|
||||||
{
|
{
|
||||||
|
@ -62,7 +62,7 @@ int RightBracket::typeMark() const
|
||||||
|
|
||||||
QString RightBracket::regex() const { return u8"}"; }
|
QString RightBracket::regex() const { return u8"}"; }
|
||||||
|
|
||||||
QString ReferMark::reviseWords() const { return u8"@"; }
|
QString ReferMark::reviseWords() const { return u8"'@'"; }
|
||||||
|
|
||||||
int ReferMark::typeMark() const
|
int ReferMark::typeMark() const
|
||||||
{
|
{
|
||||||
|
@ -144,7 +144,7 @@ VTextSection::analysis(std::shared_ptr<const IWordBase> content) const {
|
||||||
return std::make_tuple(tinst, nullptr);
|
return std::make_tuple(tinst, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Split::reviseWords() const { return u8"&"; }
|
QString Split::reviseWords() const { return u8"'&'"; }
|
||||||
|
|
||||||
int Split::typeMark() const
|
int Split::typeMark() const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue