From 4b12f27165efb0c7b38ae9338c6ec3cc42b4f6b5 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 14 Jan 2017 09:42:04 -0500 Subject: insert file list: gather & make available a list of insert files (if any) --- org/ao_read_source_files.org | 23 ++++++++++++++++++----- org/sdp.org | 5 +++++ src/sdp.d | 5 +++++ src/sdp/ao_read_source_files.d | 23 ++++++++++++++++++----- 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/org/ao_read_source_files.org b/org/ao_read_source_files.org index 819f1ff..1ab28bf 100644 --- a/org/ao_read_source_files.org +++ b/org/ao_read_source_files.org @@ -93,20 +93,25 @@ template SiSUmarkupRaw() { } final auto sourceContentSplitIntoHeaderAndBody(in string source_txt_str, in string fn_src="") { auto raw = MarkupRawUnit(); + string[] insert_file_list; auto t = raw.markupSourceHeaderContentRawLineTupleArray(source_txt_str); auto header_raw = t[0]; auto sourcefile_body_content = t[1]; if (match(fn_src, rgx.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise auto ins = Inserts(); - sourcefile_body_content = + auto tu = ins.scan_master_src_for_insert_files_and_import_content(sourcefile_body_content, fn_src); + static assert(!isTypeTuple!(tu)); + sourcefile_body_content = tu[0]; + insert_file_list = tu[1].dup; } t = tuple( header_raw, - sourcefile_body_content + sourcefile_body_content, + insert_file_list ); - static assert(t.length==2); + static assert(t.length==3); return t; } } @@ -321,13 +326,15 @@ auto markupSourceReadIn(in string fn_src) { #+name: ao_markup_source_raw_tuple_of_header_and_body #+BEGIN_SRC d auto markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) { + string[] file_insert_list = []; auto hc = header0Content1(source_txt_str); auto header = hc[0]; char[] source_txt = hc[1]; auto source_line_arr = markupSourceLineArray(source_txt); auto t = tuple( header, - source_line_arr + source_line_arr, + file_insert_list ); return t; } @@ -457,6 +464,7 @@ char[][] contents; auto type = flags_type_init; auto fn_pth_full = match(fn_src, rgx.src_pth); auto markup_src_file_path = fn_pth_full.captures[1]; +string[] insert_file_list =[]; #+END_SRC **** loop master scan for inserts (insert documents) @@ -484,6 +492,7 @@ if (type["curly_code"] == 1) { auto insert_sub_pth = m.captures[1]; auto fn_src_insert = chainPath(markup_src_file_path, insert_sub_pth ~ insert_fn).array; + insert_file_list ~= to!string(fn_src_insert); auto raw = MarkupRawUnit(); /+ TODO +/ if (auto ma = match(line, rgx.src_fn_text)) { @@ -528,7 +537,11 @@ debug(insert) { // insert file writeln(__LINE__); writeln(contents.length); } -return contents; +auto t = tuple( + contents, + insert_file_list +); +return t; #+END_SRC * figure out diff --git a/org/sdp.org b/org/sdp.org index 54a36a3..c6d0ad1 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -405,6 +405,7 @@ auto read_in_file_string = raw.sourceContent(fn_src); auto header_and_body_tuple = raw.sourceContentSplitIntoHeaderAndBody(read_in_file_string, fn_src); auto header = header_and_body_tuple[0]; auto content_body = header_and_body_tuple[1]; +auto _file_insert_list = header_and_body_tuple[2]; debug(header_and_body) { writeln(header); writeln(header_and_body_tuple.length); @@ -501,6 +502,10 @@ struct DocumentMatters { string _k = fn_src; return _k; } + auto file_insert_list() { + string[] _k = _file_insert_list; + return _k; + } auto opt_action_bool() { bool[string] _k = _opt_action_bool; return _k; diff --git a/src/sdp.d b/src/sdp.d index cf8af49..f3fd07f 100755 --- a/src/sdp.d +++ b/src/sdp.d @@ -210,6 +210,7 @@ void main(string[] args) { auto header_and_body_tuple = raw.sourceContentSplitIntoHeaderAndBody(read_in_file_string, fn_src); auto header = header_and_body_tuple[0]; auto content_body = header_and_body_tuple[1]; + auto _file_insert_list = header_and_body_tuple[2]; debug(header_and_body) { writeln(header); writeln(header_and_body_tuple.length); @@ -283,6 +284,10 @@ void main(string[] args) { string _k = fn_src; return _k; } + auto file_insert_list() { + string[] _k = _file_insert_list; + return _k; + } auto opt_action_bool() { bool[string] _k = _opt_action_bool; return _k; diff --git a/src/sdp/ao_read_source_files.d b/src/sdp/ao_read_source_files.d index a2bf75d..34aed22 100644 --- a/src/sdp/ao_read_source_files.d +++ b/src/sdp/ao_read_source_files.d @@ -23,20 +23,25 @@ template SiSUmarkupRaw() { } final auto sourceContentSplitIntoHeaderAndBody(in string source_txt_str, in string fn_src="") { auto raw = MarkupRawUnit(); + string[] insert_file_list; auto t = raw.markupSourceHeaderContentRawLineTupleArray(source_txt_str); auto header_raw = t[0]; auto sourcefile_body_content = t[1]; if (match(fn_src, rgx.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise auto ins = Inserts(); - sourcefile_body_content = + auto tu = ins.scan_master_src_for_insert_files_and_import_content(sourcefile_body_content, fn_src); + static assert(!isTypeTuple!(tu)); + sourcefile_body_content = tu[0]; + insert_file_list = tu[1].dup; } t = tuple( header_raw, - sourcefile_body_content + sourcefile_body_content, + insert_file_list ); - static assert(t.length==2); + static assert(t.length==3); return t; } } @@ -92,13 +97,15 @@ template SiSUmarkupRaw() { return source_txt_str; } auto markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) { + string[] file_insert_list = []; auto hc = header0Content1(source_txt_str); auto header = hc[0]; char[] source_txt = hc[1]; auto source_line_arr = markupSourceLineArray(source_txt); auto t = tuple( header, - source_line_arr + source_line_arr, + file_insert_list ); return t; } @@ -209,6 +216,7 @@ template SiSUmarkupRaw() { auto type = flags_type_init; auto fn_pth_full = match(fn_src, rgx.src_pth); auto markup_src_file_path = fn_pth_full.captures[1]; + string[] insert_file_list =[]; foreach (line; sourcefile_body_content) { if (type["curly_code"] == 1) { if (matchFirst(line, rgx.block_curly_code_close)) { @@ -231,6 +239,7 @@ template SiSUmarkupRaw() { auto insert_sub_pth = m.captures[1]; auto fn_src_insert = chainPath(markup_src_file_path, insert_sub_pth ~ insert_fn).array; + insert_file_list ~= to!string(fn_src_insert); auto raw = MarkupRawUnit(); /+ TODO +/ if (auto ma = match(line, rgx.src_fn_text)) { @@ -270,7 +279,11 @@ template SiSUmarkupRaw() { writeln(__LINE__); writeln(contents.length); } - return contents; + auto t = tuple( + contents, + insert_file_list + ); + return t; } } } -- cgit v1.2.3