diff options
author | Ralph Amissah <ralph@amissah.com> | 2016-06-16 01:49:06 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-04 14:48:18 -0400 |
commit | 8ab7e935913c102fb039110e20b71f698a68c6ee (patch) | |
tree | 3472debd16ce656a57150399ce666e248565f011 /src/sdp/ao_read_source_files.d | |
parent | step4.1 as step4 but extract header meta & make on first reading in document (diff) |
step5 sdlang used for config files and doc headers
Diffstat (limited to 'src/sdp/ao_read_source_files.d')
-rw-r--r-- | src/sdp/ao_read_source_files.d | 59 |
1 files changed, 56 insertions, 3 deletions
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, |