aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdp')
-rw-r--r--src/sdp/ao_abstract_doc_source.d125
-rw-r--r--src/sdp/ao_header_extract.d334
-rw-r--r--src/sdp/ao_output_debugs.d152
-rw-r--r--src/sdp/ao_read_config_files.d71
-rw-r--r--src/sdp/ao_read_source_files.d59
5 files changed, 146 insertions, 595 deletions
diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d
index ca435ff..c814c15 100644
--- a/src/sdp/ao_abstract_doc_source.d
+++ b/src/sdp/ao_abstract_doc_source.d
@@ -120,11 +120,8 @@ template SiSUdocAbstraction() {
// mixin SiSUdocAbstractionFunctions;
/+ ↓ abstract marked up document +/
- auto abstract_doc_source(
- char[][] markup_sourcefile_content,
- JSONValue[string] dochead_make_json,
- JSONValue[string] dochead_meta_json
- ) {
+ auto abstract_doc_source(char[][] markup_sourcefile_content) {
+
/+ ↓ abstraction init +/
scope(success) {
}
@@ -341,24 +338,24 @@ template SiSUdocAbstraction() {
&& ((type["para"] == State.off)
&& (type["heading"] == State.off))) {
/+ heading or para but neither flag nor line exists +/
- if ((to!string(dochead_make_json["make"]["headings"]).length > 2)
- && (type["make_headings"] == State.off)) {
- /+ heading found +/
- auto dochead_make_headings =
- to!string(dochead_make_json["make"]["headings"]);
- heading_found(line, dochead_make_headings, heading_match_str, heading_match_rgx, type);
- }
+ // if ((to!string(dochead_make["make"]["headings"]).length > 2)
+ // && (type["make_headings"] == State.off)) {
+ // /+ heading found +/
+ // auto dochead_make_headings =
+ // to!string(dochead_make["make"]["headings"]);
+ // heading_found(line, dochead_make_headings, heading_match_str, heading_match_rgx, type);
+ // }
if ((type["make_headings"] == State.on)
&& ((line_occur["para"] == State.off)
&& (line_occur["heading"] == State.off))
&& ((type["para"] == State.off)
&& (type["heading"] == State.off))) {
/+ heading make set +/
- heading_make_set(line, line_occur, heading_match_rgx, type);
+ // heading_make_set(line, line_occur, heading_match_rgx, type);
}
if (matchFirst(line, rgx.heading)) {
/+ heading match +/
- heading_matched(line, line_occur, an_object, lv, collapsed_lev, type, dochead_meta_json);
+ heading_matched(line, line_occur, an_object, lv, collapsed_lev, type);
} else if (line_occur["para"] == State.off) {
/+ para match +/
para_match(line, an_object, indent, bullet, type, line_occur);
@@ -1617,94 +1614,6 @@ template SiSUdocAbstraction() {
}
}
}
- auto heading_found(
- char[] line,
- string dochead_make_headings,
- ref string[string] heading_match_str,
- ref Regex!(char)[string] heading_match_rgx,
- ref int[string] type
- ) {
- if ((to!string(dochead_make_headings).length > 2)
- && (type["make_headings"] == State.off)) {
- /+ headings found +/
- debug(headingsfound) {
- writeln(dochead_make_headings);
- }
- auto make_headings_txt =
- match(
- to!string(dochead_make_headings),
- rgx.within_quotes);
- char[][] make_headings_spl =
- split(
- cast(char[]) make_headings_txt.captures[1],
- rgx.make_heading_delimiter);
- debug(headingsfound) {
- writeln(make_headings_spl.length);
- writeln(make_headings_spl);
- }
- switch (make_headings_spl.length) {
- case 7 :
- if (!empty(make_headings_spl[6])) {
- heading_match_str["h_4"] =
- "^(" ~ to!string(make_headings_spl[6]) ~ ")";
- heading_match_rgx["h_4"] =
- regex(heading_match_str["h_4"]);
- }
- goto case;
- case 6 :
- if (!empty(make_headings_spl[5])) {
- heading_match_str["h_3"] =
- "^(" ~ to!string(make_headings_spl[5]) ~ ")";
- heading_match_rgx["h_3"] =
- regex(heading_match_str["h_3"]);
- }
- goto case;
- case 5 :
- if (!empty(make_headings_spl[4])) {
- heading_match_str["h_2"] =
- "^(" ~ to!string(make_headings_spl[4]) ~ ")";
- heading_match_rgx["h_2"] =
- regex(heading_match_str["h_2"]);
- }
- goto case;
- case 4 :
- if (!empty(make_headings_spl[3])) {
- heading_match_str["h_1"] =
- "^(" ~ to!string(make_headings_spl[3]) ~ ")";
- heading_match_rgx["h_1"] =
- regex(heading_match_str["h_1"]);
- }
- goto case;
- case 3 :
- if (!empty(make_headings_spl[2])) {
- heading_match_str["h_D"] =
- "^(" ~ to!string(make_headings_spl[2]) ~ ")";
- heading_match_rgx["h_D"] =
- regex(heading_match_str["h_D"]);
- }
- goto case;
- case 2 :
- if (!empty(make_headings_spl[1])) {
- heading_match_str["h_C"] =
- "^(" ~ to!string(make_headings_spl[1]) ~ ")";
- heading_match_rgx["h_C"] =
- regex(heading_match_str["h_C"]);
- }
- goto case;
- case 1 :
- if (!empty(make_headings_spl[0])) {
- heading_match_str["h_B"] =
- "^(" ~ to!string(make_headings_spl[0]) ~ ")";
- heading_match_rgx["h_B"] =
- regex(heading_match_str["h_B"]);
- }
- break;
- default:
- break;
- }
- type["make_headings"] = State.on;
- }
- }
auto heading_make_set(
ref char[] line,
ref int[string] line_occur,
@@ -1767,8 +1676,8 @@ template SiSUdocAbstraction() {
ref string[string] an_object,
ref int[string] lv,
ref int[string] collapsed_lev,
- ref int[string] type,
- ref JSONValue[string] dochead_meta_json
+ ref int[string] type
+ // ref JSONValue[string] dochead_meta_json
) {
if (auto m = match(line, rgx.heading)) {
/+ heading match +/
@@ -1782,10 +1691,10 @@ template SiSUdocAbstraction() {
assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels
switch (an_object["lev"]) {
case "A":
- an_object["obj"]=replaceFirst(an_object["obj"], rgx.head_value_title, to!string(dochead_meta_json["title"]["main"]));
- an_object["obj"]=replaceFirst(an_object["obj"], rgx.head_value_author, to!string(dochead_meta_json["creator"]["author"]));
- // an_object["obj"]=replaceFirst(an_object["obj"], rgx.head_value_title, to!string(parseJSON(dochead_meta_json["title"]["main"])));
- // an_object["obj"]=replaceFirst(an_object["obj"], rgx.head_value_author, to!string(parseJSON(dochead_meta_json["creator"]["author"])));
+ // an_object["obj"]=replaceFirst(an_object["obj"], rgx.head_value_title, to!string(dochead_metadata["title"]["main"]));
+ // an_object["obj"]=replaceFirst(an_object["obj"], rgx.head_value_author, to!string(dochead_metadata["creator"]["author"]));
+ // // an_object["obj"]=replaceFirst(an_object["obj"], rgx.head_value_title, to!string(parseJSON(dochead_metadata["title"]["main"])));
+ // // an_object["obj"]=replaceFirst(an_object["obj"], rgx.head_value_author, to!string(parseJSON(dochead_metadata["creator"]["author"])));
collapsed_lev["h0"] = 1;
an_object["lev_collapsed_number"] =
to!string(collapsed_lev["h0"]);
diff --git a/src/sdp/ao_header_extract.d b/src/sdp/ao_header_extract.d
deleted file mode 100644
index 7858406..0000000
--- a/src/sdp/ao_header_extract.d
+++ /dev/null
@@ -1,334 +0,0 @@
-/+
- extract header return json
-+/
-template SiSUheaderExtract() {
- private import
- std.exception,
- std.regex,
- std.utf,
- std.conv : to;
- private import
- ao_rgx; // ao_defaults.d
- struct HeaderDocMetadataMakeJson {
- mixin SiSUrgxInitFlags;
- mixin RgxInit;
- auto rgx = Rgx();
- enum State { off, on }
- string hm, hs;
- auto header_metadata_and_make_jsonstr(
- string header,
- JSONValue[string] dochead_meta,
- JSONValue[string] dochead_make
- )
- in { }
- body {
- scope(exit) {
- destroy(header);
- destroy(dochead_meta);
- destroy(dochead_make);
- }
- if (auto t = match(header, rgx.head_main)) {
- char[][] obj_spl = split(
- cast(char[]) header,
- rgx.line_delimiter_ws_strip
- );
- auto hm = to!string(t.captures[1]);
- if (match(hm, rgx.main_headers)) {
- foreach (line; obj_spl) {
- if (auto m = match(line, rgx.head_main)) {
- if (!empty(m.captures[2])) {
- if (hm == "creator") {
- dochead_meta[hm]["author"].str =
- to!string(m.captures[2]);
- } else if (hm == "title") {
- dochead_meta[hm]["main"].str =
- to!string(m.captures[2]);
- } else if (hm == "publisher") {
- dochead_meta[hm]["name"].str =
- to!string(m.captures[2]);
- }
- }
- } else if (auto s = match(line, rgx.head_sub)) {
- if (!empty(s.captures[2])) {
- auto hs = to!string(s.captures[1]);
- if ((hm == "make" )
- && (dochead_make[hm].type() == JSON_TYPE.OBJECT)) {
- switch (hm) {
- case "make":
- if (match(hs, rgx.subhead_make)) {
- if (dochead_make[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_make[hm][hs].str = to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- default:
- break;
- }
- } else if (dochead_meta[hm].type() == JSON_TYPE.OBJECT) {
- switch (hm) {
- case "creator":
- if (match(hs, rgx.subhead_creator)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "title":
- if (match(hs, rgx.subhead_title)) {
- if ((hs == "subtitle")
- && (dochead_meta[hm]["sub"].type() == JSON_TYPE.STRING)) {
- dochead_meta[hm]["sub"].str =
- to!string(s.captures[2]);
- } else if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "rights":
- if (match(hs, rgx.subhead_rights)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "date":
- if (match(hs, rgx.subhead_date)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "original":
- if (match(hs, rgx.subhead_original)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "classify":
- if (match(hs, rgx.subhead_classify)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "identifier":
- if (match(hs, rgx.subhead_identifier)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "notes":
- if (match(hs, rgx.subhead_notes)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "publisher":
- if (match(hs, rgx.subhead_publisher)) {
- if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- dochead_meta[hm][hs].str =
- to!string(s.captures[2]);
- }
- } else {
- writeln("not a valid header type:", hm, ":", hs);
- destroy(hm);
- destroy(hs);
- }
- break;
- case "links":
- destroy(hm);
- destroy(hs);
- // if (match(hs, rgx.subhead_links)) {
- // if (dochead_meta[hm][hs].type() == JSON_TYPE.STRING) {
- // dochead_meta[hm][hs].str = to!string(s.captures[2]);
- // }
- // } else {
- // writeln("not a valid header type:", hm, ":", hs);
- // destroy(hm);
- // destroy(hs);
- // }
- break;
- default:
- break;
- }
- }
- }
- }
- }
- } else {
- writeln("not a valid header type:", hm);
- }
- }
- auto t = tuple(dochead_meta, dochead_make);
- static assert(!isTypeTuple!(t));
- return t;
- }
- private auto header_extract(
- char[] line,
- ref int[string] line_occur,
- ref string[string] an_object,
- ref int[string] type
- ) {
- if (matchFirst(line, rgx.header_make)) {
- /+ matched header_make +/
- debug(header1) { // header
- // tell_l("yellow", line);
- }
- type["header"] = State.on;
- type["header_make"] = State.on;
- type["header_meta"] = State.off;
- ++line_occur["header_make"];
- an_object["obj"] ~= line ~= "\n";
- } else if (matchFirst(line, rgx.header_meta)) {
- /+ matched header_metadata +/
- debug(header1) { // header
- // tell_l("yellow", line);
- }
- type["header"] = State.on;
- type["header_make"] = State.off;
- type["header_meta"] = State.on;
- ++line_occur["header_meta"];
- an_object["obj"] ~= line ~= "\n";
- } else if (type["header_make"] == State.on
- && (line_occur["header_make"] > State.off)) {
- /+ header_make flag set +/
- if (matchFirst(line, rgx.header_sub)) {
- /+ sub-header +/
- debug(header1) {
- // tell_l("yellow", line);
- }
- // type["header"] = State.on;
- ++line_occur["header_make"];
- an_object["obj"] ~= line ~= "\n";
- }
- } else if (type["header_meta"] == State.on
- && (line_occur["header_meta"] > State.off)) {
- /+ header_metadata flag set +/
- if (matchFirst(line, rgx.header_sub)) {
- /+ sub-header +/
- debug(header1) {
- // tell_l("yellow", line);
- }
- ++line_occur["header_meta"];
- an_object["obj"] ~= line ~= "\n";
- }
- }
- // return 0;
- return an_object;
- }
- auto header_set_common(
- ref int[string] line_occur,
- ref string[string] an_object,
- ref int[string] type
- ) {
- // line_occur["header"] = State.off;
- line_occur["header_make"] = State.off;
- line_occur["header_meta"] = State.off;
- type["header"] = State.off;
- // type["header_make"] = State.off;
- // type["header_meta"] = State.off;
- an_object.remove("obj");
- an_object.remove("is");
- an_object.remove("attrib");
- }
- private auto headerContentJSON(in char[] src_header) {
- auto type = flags_type_init;
- type = [
- "header" : State.off,
- "header_make" : State.off,
- "header_meta" : State.off,
- ];
- string[string] an_object;
- int[string] line_occur;
- auto dochead_make = parseJSON(header_make_jsonstr).object;
- auto dochead_meta = parseJSON(header_meta_jsonstr).object;
- auto set_header = HeaderDocMetadataMakeJson();
- char[][] source_header_arr =
- split(cast(char[]) src_header, rgx.line_delimiter);
- foreach(header_line; source_header_arr) {
- if (auto m = matchFirst(header_line, rgx.comment)) {
- /+ matched comment +/
- debug(comment) {
- // tell_l("blue", header_line);
- }
- header_set_common(line_occur, an_object, type);
- // type["header_make"] = State.off;
- // type["header_meta"] = State.off;
- } else if ((matchFirst(header_line, rgx.header))
- || (type["header_make"] == State.on
- && (line_occur["header_make"] > State.off))
- || (type["header_meta"] == State.on
- && (line_occur["header_meta"] > State.off))) {
- if (header_line.length == 0) {
- /+ header_make instructions (current line empty) +/
- auto dochead_metadata_and_make =
- set_header.header_metadata_and_make_jsonstr(strip(an_object["obj"]), dochead_meta, dochead_make);
- static assert(!isTypeTuple!(dochead_metadata_and_make));
- dochead_meta = dochead_metadata_and_make[0];
- dochead_make = dochead_metadata_and_make[1];
- header_set_common(line_occur, an_object, type);
- type["header_make"] = State.off;
- type["header_meta"] = State.off;
- writeln(dochead_metadata_and_make);
- } else {
- an_object = header_extract(header_line, line_occur, an_object, type);
- }
- } else {
- // writeln(__LINE__);
- }
- }
- auto t = tuple(
- dochead_make,
- dochead_meta,
- );
- return t;
- }
- }
-}
diff --git a/src/sdp/ao_output_debugs.d b/src/sdp/ao_output_debugs.d
index 3c97640..525ebcc 100644
--- a/src/sdp/ao_output_debugs.d
+++ b/src/sdp/ao_output_debugs.d
@@ -8,8 +8,8 @@ template SiSUoutputDebugs() {
auto ref const S contents,
string[][string][string] bookindex_unordered_hashes,
JSONValue[] biblio,
- JSONValue[string] dochead_make,
- JSONValue[string] dochead_meta,
+ // JSONValue[string] dochead_make,
+ // JSONValue[string] dochead_meta,
string fn_src,
bool[string] opt_action_bool
) {
@@ -76,154 +76,6 @@ template SiSUoutputDebugs() {
}
}
}
- debug(headermakejson) {
- writefln(
- "%s\n%s\n%s",
- "document header, metadata & make instructions:",
- dochead_meta,
- pointer_head_main,
- );
- foreach (main_header; pointer_head_main) {
- switch (main_header) {
- case "make":
- foreach (sub_header; pointer_head_sub_make) {
- if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
- writefln(
- "%s:%s: %s",
- main_header,
- sub_header,
- dochead_meta[main_header][sub_header]
- );
- }
- }
- break;
- default:
- break;
- }
- }
- }
- debug(headermetadatajson) {
- writefln(
- "%s\n%s\n%s",
- "document header, metadata & make instructions:",
- dochead_meta,
- pointer_head_main,
- );
- foreach (main_header; pointer_head_main) {
- switch (main_header) {
- case "creator":
- foreach (sub_header; pointer_head_sub_creator) {
- if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
- writefln(
- "%s:%s: %s",
- main_header,
- sub_header,
- dochead_meta[main_header][sub_header]
- );
- }
- }
- break;
- case "title":
- foreach (sub_header; pointer_head_sub_title) {
- if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
- writefln(
- "%s:%s: %s",
- main_header,
- sub_header,
- dochead_meta[main_header][sub_header]
- );
- }
- }
- break;
- case "rights":
- foreach (sub_header; pointer_head_sub_rights) {
- if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
- writefln(
- "%s:%s: %s",
- main_header,
- sub_header,
- dochead_meta[main_header][sub_header]
- );
- }
- }
- break;
- case "date":
- foreach (sub_header; pointer_head_sub_date) {
- if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
- writefln(
- "%s:%s: %s",
- main_header,
- sub_header,
- dochead_meta[main_header][sub_header]
- );
- }
- }
- break;
- case "original":
- foreach (sub_header; pointer_head_sub_original) {
- if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
- writefln(
- "%s:%s: %s",
- main_header,
- sub_header,
- dochead_meta[main_header][sub_header]
- );
- }
- }
- break;
- case "classify":
- foreach (sub_header; pointer_head_sub_classify) {
- if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
- writefln(
- "%s:%s: %s",
- main_header,
- sub_header,
- dochead_meta[main_header][sub_header]
- );
- }
- }
- break;
- case "identifier":
- foreach (sub_header; pointer_head_sub_identifier) {
- if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
- writefln(
- "%s:%s: %s",
- main_header,
- sub_header,
- dochead_meta[main_header][sub_header]
- );
- }
- }
- break;
- case "notes":
- foreach (sub_header; pointer_head_sub_notes) {
- if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
- writefln(
- "%s:%s: %s",
- main_header,
- sub_header,
- dochead_meta[main_header][sub_header]
- );
- }
- }
- break;
- case "publisher":
- foreach (sub_header; pointer_head_sub_publisher) {
- if (to!string(dochead_meta[main_header][sub_header]).length > 2) {
- writefln(
- "%s:%s: %s",
- main_header,
- sub_header,
- dochead_meta[main_header][sub_header]
- );
- }
- }
- break;
- default:
- break;
- }
- }
- }
debug(bookindex) {
writefln(
"%s\n%s:%s",
diff --git a/src/sdp/ao_read_config_files.d b/src/sdp/ao_read_config_files.d
new file mode 100644
index 0000000..47980da
--- /dev/null
+++ b/src/sdp/ao_read_config_files.d
@@ -0,0 +1,71 @@
+/+
+ ao_config_files.d
+ - read config files
++/
+template SiSUconfiguration() {
+ private import
+ std.exception,
+ // std.regex,
+ std.stdio,
+ std.utf,
+ std.conv : to;
+ // private import
+ // ao_rgx; // ao_defaults.d
+ // mixin RgxInit;
+ // auto rgx = Rgx();
+ private
+ struct Config {
+ private import std.file;
+ final private string readInConfigFile() {
+ // enforce(
+ // exists(fn_src)!=0,
+ // "file not found"
+ // );
+ string[] possible_config_path_locations = [
+ environment["PWD"] ~ "/.sisu",
+ environment["PWD"] ~ "/_sisu",
+ environment["HOME"] ~ "/.sisu",
+ "/etc/sisu"
+ ];
+ string conf_sdl = "conf.sdl";
+ string config_file_str;
+ foreach(pth; possible_config_path_locations) {
+ auto conf_file = format(
+ "%s/%s",
+ pth,
+ conf_sdl,
+ );
+ // writeln(conf_file);
+ try {
+ if (exists(conf_file)) {
+ writeln(conf_file);
+ config_file_str = readText(conf_file);
+ break;
+ }
+ }
+ catch (ErrnoException ex) {
+ //// Handle errors
+ // switch(ex.errno) {
+ // case EPERM:
+ // case EACCES:
+ // // Permission denied
+ // break;
+ // case ENOENT:
+ // // File does not exist
+ // break;
+ // default:
+ // // Handle other errors
+ // break;
+ // }
+ }
+ // catch (UTFException ex) {
+ // // Handle validation errors
+ // }
+ catch (FileException ex) {
+ // Handle errors
+ }
+ }
+ return config_file_str;
+ }
+ }
+}
diff --git a/src/sdp/ao_read_source_files.d b/src/sdp/ao_read_source_files.d
index e450bc8..ef9b8b4 100644
--- a/src/sdp/ao_read_source_files.d
+++ b/src/sdp/ao_read_source_files.d
@@ -20,7 +20,7 @@ template SiSUmarkupRaw() {
auto raw = MarkupRawUnit();
auto t =
raw.markupSourceHeaderContentRawLineTupleArray(fn_src, rgx.src_pth);
- auto header_content_raw = t[0];
+ auto header_raw = t[0];
auto sourcefile_content = t[1];
if (match(fn_src, rgx.src_fn_master)) {
auto ins = Inserts();
@@ -29,16 +29,69 @@ template SiSUmarkupRaw() {
// auto ins = SiSUdocInserts.Inserts();
}
t = tuple(
- header_content_raw,
+ header_raw,
sourcefile_content
);
return t;
}
}
private
+ struct HeaderExtractSDL {
+ final private auto headerMakeSDLang(in string src_header) {
+ scope(failure) {
+ stderr.writefln(
+ "%s\n%s\n%s:%s failed here:\n src_header: %s",
+ __MODULE__, __FUNCTION__,
+ __FILE__, __LINE__,
+ src_header,
+ );
+ }
+ Tag sdl_root_header;
+ try {
+ sdl_root_header = parseSource(src_header);
+ }
+ catch(SDLangParseException e) {
+ stderr.writeln("SDLang problem with this document header:");
+ stderr.writeln(src_header);
+ // Error messages of the form:
+ // myFile.sdl(5:28): Error: Invalid integer suffix.
+ stderr.writeln(e.msg);
+ }
+ debug(sdlang) {
+ // // Value is a std.variant.Algebraic
+ // Value output_dir_structure_by = sdl_root_header.tags["output_dir_structure_by"][0].values[0];
+ // assert(output_dir_structure_by.type == typeid(string));
+ // writeln(output_dir_structure_by);
+
+ // Tag person = sdl_root_header.namespaces["myNamespace"].tags["person"][0];
+ // writeln("Name: ", person.attributes["name"][0].value);
+ //
+ // int age = person.tags["age"][0].values[0].get!int();
+ // writeln("Age: ", age);
+
+ writeln("header SDL:");
+ writeln(sdl_root_header.toSDLDocument());
+ }
+ return sdl_root_header;
+ }
+ private auto headerSDLang(in char[] src_header) {
+ char[][] source_header_arr =
+ split(cast(char[]) src_header, rgx.line_delimiter);
+ char[] header_clean;
+ foreach(header_line; source_header_arr) {
+ if (!match(header_line, rgx.comments)) {
+ header_clean ~= header_line ~ "\n";
+ // writeln(header_line);
+ }
+ }
+ // writeln(header_clean); // consider
+ auto header_sdlang=headerMakeSDLang(to!string(header_clean));
+ return header_sdlang;
+ }
+ }
struct MarkupRawUnit {
private import std.file;
- enum State { off, on }
+ // enum State { off, on }
final private string readInMarkupSource(in string fn_src) {
enforce(
exists(fn_src)!=0,