注释冗余代码

This commit is contained in:
codeboss 2024-04-05 20:51:20 +08:00
parent 81db04b444
commit 3ef65d13e8
5 changed files with 74 additions and 66 deletions

View File

@ -3,11 +3,12 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerWorkingDirectory>$(SolutionDir)$(Platform)\$(Configuration)\</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>-path D:\Projects\Cpp\WsNovelParser\x64\test_file</LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtLastBackgroundBuild>2024-04-04T04:12:24.0605703Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-04-04T05:44:26.2812331Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtLastBackgroundBuild>2024-04-04T04:12:24.5356632Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-04-04T05:44:26.7768638Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>

View File

@ -16,73 +16,80 @@
using namespace example_novel;
int main(int argc, char* argv[]) {
QCoreApplication a(argc, argv);
QCoreApplication a(argc, argv);
try {
QFileInfoList files;
files.append(QFileInfo("D:\\Projects\\Cpp\\WsNovelParser\\x64\\test_file\\description.txt"));
auto sdir = QDir::current();
if (argc >= 3 && !strcmp(argv[1], "-path")) {
auto tdir = QDir(QString::fromLocal8Bit(argv[2]));
if (tdir.exists())
sdir = tdir;
}
auto parser = std::make_shared<NovelParser>();
auto novel_accesstree = parser->parse(files);
auto files = sdir.entryInfoList(QStringList() << "*.story");
if (files.size()) {
try {
auto parser = std::make_shared<NovelParser>();
auto novel_accesstree = parser->parse(files);
printer::tools_printer tool;
tool.build_fragments(novel_accesstree);
tool.build_refers_network(novel_accesstree);
printer::tools_printer tool;
tool.build_fragments(novel_accesstree);
tool.build_refers_network(novel_accesstree);
tool.fragments_anchors_define(tool.fragment_defines.values(), QDir::current());
tool.storylines_anchors_define(tool.storyline_defines.values(), QDir::current());
tool.volumes_anchors_define(tool.volume_defines.values(), QDir::current());
tool.fragments_anchors_define(tool.fragment_defines.values(), QDir::current());
tool.storylines_anchors_define(tool.storyline_defines.values(), QDir::current());
tool.volumes_anchors_define(tool.volume_defines.values(), QDir::current());
std::function<void(std::shared_ptr<const printer::Access>)> html_output =
[](std::shared_ptr<const printer::Access> inst) {
auto target_path = inst->pageRefers();
QFile tfile(target_path);
if (tfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
QDomDocument doc_inst(QDomImplementation().createDocumentType(u8"html", QString(), QString()));
auto html = doc_inst.createElement(u8"html");
doc_inst.appendChild(html);
std::function<void(std::shared_ptr<const printer::Access>)> html_output =
[](std::shared_ptr<const printer::Access> inst) {
auto target_path = inst->pageRefers();
QFile tfile(target_path);
if (tfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
QDomDocument doc_inst(QDomImplementation().createDocumentType(u8"html", QString(), QString()));
auto html = doc_inst.createElement(u8"html");
doc_inst.appendChild(html);
auto body = doc_inst.createElement(u8"body");
html.appendChild(body);
auto body = doc_inst.createElement(u8"body");
html.appendChild(body);
inst->buildPageHTML(body);
inst->buildPageHTML(body);
QTextStream tout(&tfile);
doc_inst.save(tout, 2);
tout.flush();
}
};
QTextStream tout(&tfile);
doc_inst.save(tout, 2);
tout.flush();
}
};
for (auto& node : tool.fragment_defines)
html_output(node);
for (auto& node : tool.storyline_defines)
html_output(node);
for (auto& node : tool.volume_defines)
html_output(node);
for (auto& node : tool.fragment_defines)
html_output(node);
for (auto& node : tool.storyline_defines)
html_output(node);
for (auto& node : tool.volume_defines)
html_output(node);
std::function<void(std::shared_ptr<const ast_gen::ElementAccess>, int)> tnode_print =
[&](std::shared_ptr<const ast_gen::ElementAccess> node, int intend) {
auto name = node->element()->signature();
auto text = QString(intend * 2, ' ') + name;
for (auto& t : node->tokens()) {
text += " " + t->token()->content();
}
qDebug() << text;
std::function<void(std::shared_ptr<const ast_gen::ElementAccess>, int)> tnode_print =
[&](std::shared_ptr<const ast_gen::ElementAccess> node, int intend) {
auto name = node->element()->signature();
auto text = QString(intend * 2, ' ') + name;
/*for (auto& t : node->tokens()) {
text += " " + t->token()->content();
}*/
qDebug() << text;
for (auto& c_n : node->children()) {
tnode_print(c_n, intend + 1);
}
};
for (auto& c_n : node->children()) {
tnode_print(c_n, intend + 1);
}
};
tnode_print(novel_accesstree, 0);
}
catch (lib_syntax::SyntaxException* e) {
qDebug().noquote() << e->message();
delete e;
}
catch (lib_parse::CheckException* e) {
qDebug().noquote() << e->message();
delete e;
}
return a.exec();
tnode_print(novel_accesstree, 0);
}
catch (lib_syntax::SyntaxException* e) {
qDebug().noquote() << e->message();
delete e;
}
catch (lib_parse::CheckException* e) {
qDebug().noquote() << e->message();
delete e;
}
}
return a.exec();
}

View File

@ -5,9 +5,9 @@
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtLastBackgroundBuild>2024-04-04T04:12:25.1970080Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-04-04T05:44:26.9010407Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtLastBackgroundBuild>2024-04-04T04:12:25.4349434Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-04-04T05:44:26.9937157Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>

View File

@ -5,9 +5,9 @@
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtLastBackgroundBuild>2024-04-04T04:12:24.7411048Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-04-04T05:44:27.2679289Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtLastBackgroundBuild>2024-04-04T04:12:25.0903609Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-04-04T05:44:27.3466654Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>

View File

@ -2,9 +2,9 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtLastBackgroundBuild>2024-04-04T04:12:25.4971632Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-04-04T05:44:27.1222839Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtLastBackgroundBuild>2024-04-04T04:12:25.6489839Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-04-04T05:44:27.2278924Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>