改进错误提示
This commit is contained in:
parent
da598a5ba6
commit
90104e0e9e
|
@ -23,8 +23,9 @@ std::tuple<IBasicRule::MatchResult, std::shared_ptr<const IWordBase>> TokenMatch
|
|||
}
|
||||
else {
|
||||
rt_inst->appendParseErrors(rt_inst->currentFile(), head->position(),
|
||||
QString(u8"Syntax[0x00001]语法匹配错误,不能识别token\"%1\"<row:%2,col:%3>(应该为:%4)")
|
||||
.arg(head->content()).arg(head->row()).arg(head->column()).arg(this->define_peer->reviseWords()));
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -37,7 +38,7 @@ std::tuple<IBasicRule::MatchResult, std::shared_ptr<const IWordBase>> TokenMatch
|
|||
}
|
||||
|
||||
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(std::shared_ptr<const IBasicRule> rule, int min, int max) : rule_peer(rule), min_match(min), max_match(max) {}
|
||||
|
@ -82,7 +83,12 @@ std::tuple<IBasicRule::MatchResult, std::shared_ptr<const IWordBase>> Rept::pars
|
|||
|
||||
QString Rept::token_present() const
|
||||
{
|
||||
return u8"(" + this->rule_peer->token_present() + QString(u8"{%1, %2}").arg(min_match).arg(max_match) + u8")";
|
||||
if(min_match == 0 && max_match == INT_MAX)
|
||||
return u8"(" + this->rule_peer->token_present() + QString(u8")*");
|
||||
else 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);
|
||||
}
|
||||
|
||||
Seqs::Seqs(const QList<std::shared_ptr<const IBasicRule>> mbrs) : mbrs_store(mbrs) {}
|
||||
|
@ -114,8 +120,8 @@ QString Seqs::token_present() const
|
|||
{
|
||||
QString content;
|
||||
for (auto& it : children())
|
||||
content += it->token_present();
|
||||
return QString(u8"(%1)").arg(content);
|
||||
content += it->token_present() + " ";
|
||||
return content.mid(0, content.size() - 1);
|
||||
}
|
||||
|
||||
//std::tuple<IBasicRule::MatchResult, uint, std::shared_ptr<const IBasicRule>, std::shared_ptr<const Token>>
|
||||
|
@ -171,7 +177,7 @@ QString Any::token_present() const
|
|||
for (auto& it : children()) {
|
||||
members_content += it->token_present() + u8"|";
|
||||
}
|
||||
return u8"(" + members_content.mid(0, members_content.size() - 1) + u8")";
|
||||
return members_content.mid(0, members_content.size() - 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue