注释冗余代码

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'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerWorkingDirectory>$(SolutionDir)$(Platform)\$(Configuration)\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>$(SolutionDir)$(Platform)\$(Configuration)\</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>-path D:\Projects\Cpp\WsNovelParser\x64\test_file</LocalDebuggerCommandArguments>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <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>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <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> </PropertyGroup>
</Project> </Project>

View File

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

View File

@ -5,9 +5,9 @@
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <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>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <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> </PropertyGroup>
</Project> </Project>

View File

@ -5,9 +5,9 @@
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <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>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <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> </PropertyGroup>
</Project> </Project>

View File

@ -2,9 +2,9 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup /> <PropertyGroup />
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <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>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <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> </PropertyGroup>
</Project> </Project>