slash
This commit is contained in:
parent
d41427a3a3
commit
f58a034df2
|
@ -42,7 +42,9 @@ QList<std::shared_ptr<const ast_basic::IExprInst>> NovelParser::parse(const QFil
|
||||||
for (auto& file : source_list) {
|
for (auto& file : source_list) {
|
||||||
context->setCurrentFile(file.canonicalFilePath());
|
context->setCurrentFile(file.canonicalFilePath());
|
||||||
auto words = word_reader->wordsFrom(file.canonicalFilePath());
|
auto words = word_reader->wordsFrom(file.canonicalFilePath());
|
||||||
this->syntax_defines->parse(context, words);
|
|
||||||
|
lib_syntax::IBasicRule::ErrOccurs modify = lib_syntax::IBasicRule::ErrOccurs::None;
|
||||||
|
this->syntax_defines->parse(context, words, modify);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<std::shared_ptr<const ast_basic::IExprInst>> forst_root = context->getDocInsts();
|
QList<std::shared_ptr<const ast_basic::IExprInst>> forst_root = context->getDocInsts();
|
||||||
|
|
|
@ -76,7 +76,7 @@ std::shared_ptr<const IBasicRule> ExpressionContext::popExprRule()
|
||||||
return rule_stack.takeLast();
|
return rule_stack.takeLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpressionContext::appendParseErrors(const QString& file_path, int start, const QString& e) {
|
void ExpressionContext::appendParseError(const QString& file_path, int start, const QString& e) {
|
||||||
this->errors_storage.append(std::make_tuple(file_path, start, e));
|
this->errors_storage.append(std::make_tuple(file_path, start, e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ namespace ast_basic {
|
||||||
virtual void appendDocInst(std::shared_ptr<ast_basic::IExprInst> inst) override;
|
virtual void appendDocInst(std::shared_ptr<ast_basic::IExprInst> inst) override;
|
||||||
virtual QList<std::shared_ptr<const ast_basic::IExprInst>> getDocInsts() const override;
|
virtual QList<std::shared_ptr<const ast_basic::IExprInst>> getDocInsts() const override;
|
||||||
|
|
||||||
void appendParseErrors(const QString& file_path, int start, const QString& error_msg) override;
|
void appendParseError(const QString& file_path, int start, const QString& error_msg) override;
|
||||||
QStringList errors() const override;
|
QStringList errors() const override;
|
||||||
void clearErrors(const QString& file_path, int start) override;
|
void clearErrors(const QString& file_path, int start) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -184,14 +184,15 @@ namespace lib_syntax {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::tuple<IBasicRule::MatchResult, std::shared_ptr<const lib_token::IWordBase>>
|
virtual std::tuple<IBasicRule::MatchResult, std::shared_ptr<const lib_token::IWordBase>>
|
||||||
parse(std::shared_ptr<IContext> rt_inst, std::shared_ptr<const lib_token::IWordBase> head) const override {
|
parse(std::shared_ptr<IContext> rt_inst, std::shared_ptr<const lib_token::IWordBase> head, IBasicRule::ErrOccurs &fx_type) 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();
|
||||||
|
|
||||||
rt_inst->pushExprRule(this->shared_from_this());
|
rt_inst->pushExprRule(this->shared_from_this());
|
||||||
rt_inst->pushExprInst(elm_ast);
|
rt_inst->pushExprInst(elm_ast);
|
||||||
|
|
||||||
auto rstg = child_store->parse(rt_inst, head);
|
IBasicRule::ErrOccurs fixed = IBasicRule::ErrOccurs::None;
|
||||||
|
auto rstg = child_store->parse(rt_inst, head, fixed);
|
||||||
auto tokens_decl = elm_ast->tokens();
|
auto tokens_decl = elm_ast->tokens();
|
||||||
|
|
||||||
switch (std::get<0>(rstg)) {
|
switch (std::get<0>(rstg)) {
|
||||||
|
|
|
@ -243,7 +243,8 @@ QList<shared_ptr<const IBasicRule>> ExprRule::children() const {
|
||||||
tuple<IBasicRule::MatchResult, shared_ptr<const IWordBase>>
|
tuple<IBasicRule::MatchResult, shared_ptr<const IWordBase>>
|
||||||
ExprRule::parse(shared_ptr<IContext> rt_inst, shared_ptr<const IWordBase> head, IBasicRule::ErrOccurs& fx_type) const {
|
ExprRule::parse(shared_ptr<IContext> rt_inst, shared_ptr<const IWordBase> head, IBasicRule::ErrOccurs& fx_type) const {
|
||||||
QList<IBasicRule::ErrOccurs> opts_list = {
|
QList<IBasicRule::ErrOccurs> opts_list = {
|
||||||
IBasicRule::ErrOccurs::None, IBasicRule::ErrOccurs::Surplus, IBasicRule::ErrOccurs::Absence, IBasicRule::ErrOccurs::Replace };
|
IBasicRule::ErrOccurs::None, IBasicRule::ErrOccurs::Surplus, IBasicRule::ErrOccurs::Absence, IBasicRule::ErrOccurs::Replace
|
||||||
|
};
|
||||||
|
|
||||||
auto opt_current_itor = opts_list.cbegin();
|
auto opt_current_itor = opts_list.cbegin();
|
||||||
tuple<IBasicRule::MatchResult, shared_ptr<const IWordBase>> ret_tuple;
|
tuple<IBasicRule::MatchResult, shared_ptr<const IWordBase>> ret_tuple;
|
||||||
|
@ -256,14 +257,7 @@ ExprRule::parse(shared_ptr<IContext> rt_inst, shared_ptr<const IWordBase> head,
|
||||||
rt_inst->pushExprInst(elm_ast);
|
rt_inst->pushExprInst(elm_ast);
|
||||||
|
|
||||||
ret_tuple = child_store->parse(rt_inst, head, opt_val);
|
ret_tuple = child_store->parse(rt_inst, head, opt_val);
|
||||||
auto tokens_decl = elm_ast->tokens();
|
|
||||||
|
|
||||||
switch (get<0>(ret_tuple)) {
|
switch (get<0>(ret_tuple)) {
|
||||||
case IBasicRule::MatchResult::Fail:
|
|
||||||
case IBasicRule::MatchResult::Part:
|
|
||||||
rt_inst->popExprInst();
|
|
||||||
rt_inst->popExprRule();
|
|
||||||
break;
|
|
||||||
case IBasicRule::MatchResult::Success: {
|
case IBasicRule::MatchResult::Success: {
|
||||||
if (!dynamic_pointer_cast<example_novel::Document>(elm_ast) && opt_val == IBasicRule::ErrOccurs::None) {
|
if (!dynamic_pointer_cast<example_novel::Document>(elm_ast) && opt_val == IBasicRule::ErrOccurs::None) {
|
||||||
auto start_pos = head->position();
|
auto start_pos = head->position();
|
||||||
|
@ -279,6 +273,13 @@ ExprRule::parse(shared_ptr<IContext> rt_inst, shared_ptr<const IWordBase> head,
|
||||||
else {
|
else {
|
||||||
rt_inst->appendDocInst(elm_ast);
|
rt_inst->appendDocInst(elm_ast);
|
||||||
}
|
}
|
||||||
|
}return ret_tuple;
|
||||||
|
case IBasicRule::MatchResult::Part:
|
||||||
|
if (!dynamic_pointer_cast<example_novel::Document>(elm_ast))
|
||||||
|
rt_inst->clearErrors(rt_inst->currentFile(), head->position());
|
||||||
|
case IBasicRule::MatchResult::Fail: {
|
||||||
|
rt_inst->popExprInst();
|
||||||
|
rt_inst->popExprRule();
|
||||||
}break;
|
}break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace lib_syntax {
|
||||||
virtual void setCurrentFile(const QString &path) = 0;
|
virtual void setCurrentFile(const QString &path) = 0;
|
||||||
virtual QString currentFile() const = 0;
|
virtual QString currentFile() const = 0;
|
||||||
|
|
||||||
virtual void appendParseErrors(const QString & file_path, int start, const QString &error_msg) = 0;
|
virtual void appendParseError(const QString & file_path, int start, const QString &error_msg) = 0;
|
||||||
virtual QStringList errors() const = 0;
|
virtual QStringList errors() const = 0;
|
||||||
virtual void clearErrors(const QString &file_path, int start) = 0;
|
virtual void clearErrors(const QString &file_path, int start) = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue