2025-02-08 05:40:36 +00:00
|
|
|
#include <QtCore/QCoreApplication>
|
|
|
|
#include <libwords.h>
|
|
|
|
#include <qdebug.h>
|
|
|
|
#include <QFile>
|
|
|
|
#include <libsyntax.h>
|
|
|
|
#include <ast_gen.h>
|
2025-02-15 07:55:35 +00:00
|
|
|
#include <ast_novel.h>
|
2025-02-08 05:40:36 +00:00
|
|
|
#include <syntax_novel.h>
|
|
|
|
|
2025-02-15 07:55:35 +00:00
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
QCoreApplication a(argc, argv);
|
2025-02-08 05:40:36 +00:00
|
|
|
|
2025-02-15 15:47:42 +00:00
|
|
|
|
|
|
|
QFile in("D:\\Projects\\Cpp\\WsNovelParser\\x64\\test_file\\description - 副本.story");
|
2025-02-15 07:55:35 +00:00
|
|
|
in.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
|
|
QTextStream tt(&in);
|
2025-02-17 05:59:25 +00:00
|
|
|
//tt.setCodec("UTF-8");
|
2025-02-15 07:55:35 +00:00
|
|
|
lib_words::WordReader reader;
|
2025-02-15 15:47:42 +00:00
|
|
|
auto vwords = reader.wordsFrom(tt, "D:\\Projects\\Cpp\\WsNovelParser\\x64\\test_file\\description - 副本.story");
|
2025-02-08 05:40:36 +00:00
|
|
|
|
2025-02-15 07:55:35 +00:00
|
|
|
ast_gen::SyntaxParser parser(example_novel::NovalSyntax::getSyntaxTree());
|
|
|
|
auto rst = parser.parse(vwords);
|
2025-02-15 04:57:53 +00:00
|
|
|
|
2025-02-15 07:55:35 +00:00
|
|
|
if (rst.first()->totalErrorCount()) {
|
|
|
|
auto pos_mark = rst.first()->token()->position();
|
|
|
|
for (auto item : rst)
|
|
|
|
if (item->token()->position() == pos_mark)
|
|
|
|
for (auto line : item->totalErrors())
|
|
|
|
qDebug().noquote() << line;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
auto prag_root = std::make_shared<example_novel::NGlobalElement>("HelloWorld!");
|
|
|
|
auto structx = parser.getAst(rst.first(), prag_root);
|
|
|
|
parser.astPresent(structx);
|
|
|
|
}
|
|
|
|
qDebug() << "===========finished==========================";
|
|
|
|
return a.exec();
|
2025-02-08 05:40:36 +00:00
|
|
|
}
|