diff options
author | Ralph Amissah <ralph@amissah.com> | 2016-04-24 22:08:24 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2016-04-24 22:08:24 -0400 |
commit | ed302d1be74d2b4e69ee4b6e3834637ed531eaea (patch) | |
tree | 0f605c3756788d2fda6fe0782a7a472172a285b9 /org/ao_scan_inserts.org | |
parent | base ... tag (diff) |
step1doc-reform_v0.0.1
Diffstat (limited to 'org/ao_scan_inserts.org')
-rw-r--r-- | org/ao_scan_inserts.org | 128 |
1 files changed, 51 insertions, 77 deletions
diff --git a/org/ao_scan_inserts.org b/org/ao_scan_inserts.org index 930d875..2b76960 100644 --- a/org/ao_scan_inserts.org +++ b/org/ao_scan_inserts.org @@ -19,16 +19,10 @@ *** scan subdoc source #+name: ao_inserts_scan #+BEGIN_SRC d -char[][100000] cont_arbitrary_max_length_set_; -auto ft0 = flag_type.dup; +char[][] contents_insert; auto ft1 = flag_type.dup; -string[string] processing; -uint[string] line_occur; -auto obj_im = new ObjInlineMarkup(); -auto obj_att = new ObjAttrib(); -int[string] counter; counter["add"]=0; mixin ScreenTxtColors; -auto rgx = new Rgx(); +auto rgx = Rgx(); int tell_l(string color, in char[] line) { writeln(scr_txt_marker[color], line); return 0; @@ -36,6 +30,7 @@ int tell_l(string color, in char[] line) { auto fn_pth_full = match(fn_src, rgx.src_pth); auto markup_src_file_path = fn_pth_full.captures[1]; #+END_SRC + *** loop insert (sub-document) #+name: ao_inserts_scan_loop #+BEGIN_SRC d @@ -45,44 +40,36 @@ if (ft1["curly_code"] == 1) { if (auto m = match(line, rgx.block_curly_code_close)) { ft1["curly_code"] = 0; } - cont_arbitrary_max_length_set_[counter["add"]] = line; - ++counter["add"]; ++add; + contents_insert ~= line; } else if (auto m = match(line, rgx.block_curly_code_open)) { ft1["curly_code"] = 1; ft1["header_make"] = 0; ft1["header_metadata"] = 0; - cont_arbitrary_max_length_set_[counter["add"]] = line; - ++counter["add"]; ++add; + contents_insert ~= line; } else if (ft1["tic_code"] == 1) { ft1["header_make"] = 0; ft1["header_metadata"] = 0; if (auto m = match(line, rgx.block_tic_close)) { ft1["tic_code"] = 0; } - cont_arbitrary_max_length_set_[counter["add"]] = line; - ++counter["add"]; ++add; + contents_insert ~= line; } else if (auto m = match(line, rgx.block_tic_code_open)) { ft1["tic_code"] = 1; ft1["header_make"] = 0; ft1["header_metadata"] = 0; - cont_arbitrary_max_length_set_[counter["add"]] = line; - ++counter["add"]; ++add; + contents_insert ~= line; } else if ( - (ft1["header_make"] == 1) && (line_occur["header_make"] > 0) + (ft1["header_make"] == 1) && match(line, rgx.header_sub) ) { ft1["header_make"] = 1; ft1["header_metadata"] = 0; - ++line_occur["header_make"]; - ++counter["add"]; } else if ( - (ft1["header_metadata"] == 1) && (line_occur["header_metadata"] > 0) + (ft1["header_metadata"] == 1) && match(line, rgx.header_sub) ) { ft1["header_metadata"] = 1; ft1["header_make"] = 0; - ++line_occur["header_metadata"]; - ++counter["add"]; } else if (auto m = match(line, rgx.insert_src_fn_ssi_or_sst)) { ft1["header_make"] = 0; ft1["header_metadata"] = 0; @@ -90,7 +77,7 @@ if (ft1["curly_code"] == 1) { auto insert_sub_pth = m.captures[1]; auto fn_src_insert = (markup_src_file_path ~ insert_sub_pth ~ insert_fn); - auto raw = new MarkupRaw(); + auto raw = MarkupRaw(); auto markup_sourcesubfile_insert_content = raw.markupInsertSourceContentRawLineArray(fn_src_insert); debug(insert) { // insert file @@ -102,7 +89,7 @@ if (ft1["curly_code"] == 1) { markup_sourcesubfile_insert_content.length ); } - auto ins = new Inserts(); + auto ins = Inserts(); /+ 1. load file, 2. read lines; @@ -115,31 +102,24 @@ if (ft1["curly_code"] == 1) { } else { ft1["header_make"] = 0; ft1["header_metadata"] = 0; - cont_arbitrary_max_length_set_[counter["add"]] = line; - ++counter["add"]; ++add; + contents_insert ~= line; } #+END_SRC + *** post loop #+name: ao_inserts_scan_post #+BEGIN_SRC d -auto contents_ = cont_arbitrary_max_length_set_[0 .. counter["add"]].dup; -auto t = tuple(contents_, add); -return t; +return contents_insert; #+END_SRC ** scan document source :scan_src: *** scan doc source #+name: ao_doc_scan #+BEGIN_SRC d -char[][100000] cont_arbitrary_max_length_set; // 2000 pg * 50 lines -string[string] processing; -uint[string] line_occur; -auto obj_im = new ObjInlineMarkup(); -auto obj_att = new ObjAttrib(); +char[][] contents; auto ft = flag_type.dup; -int add; mixin ScreenTxtColors; -auto rgx = new Rgx(); +auto rgx = Rgx(); int tell_l(string color, in char[] line) { writeln(scr_txt_marker[color], line); return 0; @@ -147,6 +127,7 @@ int tell_l(string color, in char[] line) { auto fn_pth_full = match(fn_src, rgx.src_pth); auto markup_src_file_path = fn_pth_full.captures[1]; #+END_SRC + *** loop insert (document) #+name: ao_doc_scan_loop #+BEGIN_SRC d @@ -156,49 +137,42 @@ if (ft["curly_code"] == 1) { if (auto m = match(line, rgx.block_curly_code_close)) { ft["curly_code"] = 0; } - cont_arbitrary_max_length_set[add] = line; - ++add; + contents ~= line; } else if (auto m = match(line, rgx.block_curly_code_open)) { ft["curly_code"] = 1; ft["header_make"] = 0; ft["header_metadata"] = 0; - cont_arbitrary_max_length_set[add] = line; - ++add; + contents ~= line; } else if (ft["tic_code"] == 1) { ft["header_make"] = 0; ft["header_metadata"] = 0; if (auto m = match(line, rgx.block_tic_close)) { ft["tic_code"] = 0; } - cont_arbitrary_max_length_set[add] = line; - ++add; + contents ~= line; } else if (auto m = match(line, rgx.block_tic_code_open)) { ft["tic_code"] = 1; ft["header_make"] = 0; ft["header_metadata"] = 0; - cont_arbitrary_max_length_set[add] = line; -} else if ((ft["header_make"] == 1) -&& (line_occur["header_make"] > 0) -&& match(line, rgx.header_sub)) { - ++line_occur["header_make"]; - cont_arbitrary_max_length_set[add] = line; - ++add; -} else if ((ft["header_metadata"] == 1) -&& (line_occur["header_metadata"] > 0) -&& match(line, rgx.header_sub)) { - ++line_occur["header_metadata"]; - cont_arbitrary_max_length_set[add] = line; - ++add; + contents ~= line; +} else if ( + (ft["header_make"] == 1) + && match(line, rgx.header_sub) +) { + contents ~= line; +} else if ( + (ft["header_metadata"] == 1) + && match(line, rgx.header_sub) +) { + contents ~= line; } else if (auto m = match(line, rgx.header_make)) { ft["header_make"] = 1; - ++line_occur["header_make"]; - cont_arbitrary_max_length_set[add] = line; - ++add; + ft["header_metadata"] = 0; + contents ~= line; } else if (auto m = match(line, rgx.header_metadata)) { + ft["header_make"] = 0; ft["header_metadata"] = 1; - ++line_occur["header_metadata"]; - cont_arbitrary_max_length_set[add] = line; - ++add; + contents ~= line; } else if (auto m = match(line, rgx.insert_src_fn_ssi_or_sst)) { ft["header_make"] = 0; ft["header_metadata"] = 0; @@ -206,7 +180,7 @@ if (ft["curly_code"] == 1) { auto insert_sub_pth = m.captures[1]; auto fn_src_insert = (markup_src_file_path ~ insert_sub_pth ~ insert_fn); - auto raw = new MarkupRaw(); + auto raw = MarkupRaw(); auto markup_sourcefile_insert_content = raw.markupInsertSourceContentRawLineArray(fn_src_insert); debug(insert) { // insert file @@ -217,15 +191,12 @@ if (ft["curly_code"] == 1) { markup_sourcefile_insert_content.length ); } - auto ins = new Inserts(); - auto t = ins.scan_subdoc_source( - markup_sourcefile_insert_content, to!string(fn_src_insert), add + auto ins = Inserts(); + auto contents_insert = ins.scan_subdoc_source( + markup_sourcefile_insert_content, + to!string(fn_src_insert) ); - static assert(!isTypeTuple!(t)); - auto tmparr = t[0]; - auto addsub = t[1]; - cont_arbitrary_max_length_set[add .. addsub-1] = tmparr[0 .. $-1]; - add=addsub; + contents ~= contents_insert; /+ 1. load file, 2. read lines; @@ -238,18 +209,16 @@ if (ft["curly_code"] == 1) { } else { ft["header_make"] = 0; ft["header_metadata"] = 0; - cont_arbitrary_max_length_set[add] = line; - ++add; + contents ~= line; } #+END_SRC + *** post loop #+name: ao_doc_scan_post #+BEGIN_SRC d -auto contents = cont_arbitrary_max_length_set[0..add].dup; debug(insert) { // insert file writeln(__LINE__); writeln(contents.length); - writeln(add); } return contents; #+END_SRC @@ -263,9 +232,11 @@ return contents; ao_inserts.d +/ mixin template SiSUdocInserts() { - class Inserts { + private: + struct Inserts { auto scan_subdoc_source( - char[][] markup_sourcefile_insert_content, string fn_src, int add + char[][] markup_sourcefile_insert_content, + string fn_src ) { <<ao_inserts_scan>> foreach (line; markup_sourcefile_insert_content) { @@ -273,7 +244,10 @@ mixin template SiSUdocInserts() { } // end src subdoc (inserts) loop <<ao_inserts_scan_post>> } - auto scan_doc_source(char[][] markup_sourcefile_content, string fn_src) { + auto scan_doc_source( + char[][] markup_sourcefile_content, + string fn_src + ) { <<ao_doc_scan>> foreach (line; markup_sourcefile_content) { <<ao_doc_scan_loop>> |