diff options
author | Ralph Amissah <ralph@amissah.com> | 2016-06-25 06:37:22 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-04 14:48:18 -0400 |
commit | f0c845eba3718fd0c732aebf25eb33e689798e03 (patch) | |
tree | c2ea36e199950647b1d3cce153691bb8f4fec378 /org/ao_read_source_files.org | |
parent | step5.1 headers sdlang (like native headers) converted to json for common int... (diff) |
step6 headers (&config), native & sdlang to json internally
Diffstat (limited to 'org/ao_read_source_files.org')
-rw-r--r-- | org/ao_read_source_files.org | 104 |
1 files changed, 92 insertions, 12 deletions
diff --git a/org/ao_read_source_files.org b/org/ao_read_source_files.org index 52537be..c3c68ad 100644 --- a/org/ao_read_source_files.org +++ b/org/ao_read_source_files.org @@ -9,17 +9,17 @@ #+PROPERTY: header-args :padline no :exports code :noweb yes #+EXPORT_SELECT_TAGS: export #+EXPORT_EXCLUDE_TAGS: noexport -#+FILETAGS: :sdp:niu:ao: +#+FILETAGS: :sdp:rel:ao: #+TAGS: assert(a) class(c) debug(d) mixin(m) sdp(s) tangle(T) template(t) WEB(W) noexport(n) [[./sdp.org][sdp]] [[./][org/]] * get config file :config: ** [#A] read config file, source string :string: -*** config file :file:config: -#+name: ao_config_file +*** config file (conf.sdl & sisu_document_make) :file:config: +#+name: ao_config_file_in #+BEGIN_SRC d -final private string readInConfigFile() { +final private string readInConfigFile(string conf_sdl) { // enforce( // exists(fn_src)!=0, // "file not found" @@ -30,7 +30,6 @@ final private string readInConfigFile() { environment["HOME"] ~ "/.sisu", "/etc/sisu" ]; - string conf_sdl = "conf.sdl"; string config_file_str; foreach(pth; possible_config_path_locations) { auto conf_file = format( @@ -72,6 +71,50 @@ final private string readInConfigFile() { } #+END_SRC +*** config file get sdl root tag :file:conf:sdlang: + +#+name: ao_config_file_sdlang +#+BEGIN_SRC d +private auto configSDLangRootTag(string configuration, string conf_sdl_filename) { + Tag sdl_root_conf; + try { + sdl_root_conf = parseSource(configuration); + } + catch(SDLangParseException e) { + stderr.writeln("SDLang problem with content for ", conf_sdl_filename); + // 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_conf.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_conf.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("conf SDL:"); + writeln(sdl_root_conf.toSDLDocument()); + } + return sdl_root_conf; +} +#+END_SRC + +*** config file (conf.sdl & sisu_document_make) :file:config:hub: +#+name: ao_config_file_sdlang_hub +#+BEGIN_SRC d +final private auto configSDLang(string conf_sdl) { + auto conf_get = ConfigIn(); + auto configuration = conf_get.readInConfigFile(conf_sdl); + auto conf = ConfigSDLangRootTag(); + auto sdl_root = conf.configSDLangRootTag(configuration, conf_sdl); + return sdl_root; +} +#+END_SRC + * get markup source, read file :source:markup: ** [#A] read file, source string :string: @@ -138,7 +181,7 @@ catch (ErrnoException ex) { // } } -** array[0..1]: split header content :array: +** array[0..1]: split header content :array: #+name: ao_markup_source_raw #+BEGIN_SRC d final private char[][] header0Content1(in string src_text) { @@ -324,6 +367,13 @@ if (type["curly_code"] == 1) { auto fn_src_insert = to!string(markup_src_file_path ~ insert_sub_pth ~ insert_fn); auto raw = MarkupRawUnit(); + /+ TODO +/ + if (auto ma = match(line, rgx.src_fn_text)) { + /+ .sst when inserted, not used: headers and heading level ^:?A~ so remove +/ + writeln(__LINE__); writeln(ma); + // auto t = + // raw.markupSourceHeaderContentRawLineTupleArray(fn_src, rgx.src_pth); + } auto markup_sourcefile_insert_content = raw.markupSourceContentRawLineArray(fn_src_insert, rgx.src_fn_find_inserts); debug(insert) { // insert file @@ -365,7 +415,7 @@ return contents; #+END_SRC * tangles (code structure) :tangle: -** ao_markup_source_raw.d: :ao_markup_source_raw.d: +** ao_markup_source_raw.d: :ao_markup_source_raw: #+BEGIN_SRC d :tangle ../src/sdp/ao_read_source_files.d /+ @@ -444,14 +494,16 @@ INSERTS? [[./ao_scan_inserts.org][ao_scan_inserts]] WORK AREA -** config files: :ao_config_files.d: +** config files (conf.sdl & sisu_document_make) :ao_config_files: + +*** config files, read in #+BEGIN_SRC d :tangle ../src/sdp/ao_read_config_files.d /+ ao_config_files.d - read config files +/ -template SiSUconfiguration() { +template SiSUconfigIn() { private import std.exception, // std.regex, @@ -463,9 +515,37 @@ template SiSUconfiguration() { // mixin RgxInit; // auto rgx = Rgx(); private - struct Config { + struct ConfigIn { private import std.file; - <<ao_config_file>> + <<ao_config_file_in>> + } +} +#+END_SRC + +*** config files get sdlang root tag + +#+BEGIN_SRC d :tangle ../src/sdp/ao_read_config_files.d +/+ + ++/ +template SiSUconfigSDLang() { + struct ConfigSDLangRootTag { + <<ao_config_file_sdlang>> + } +} +#+END_SRC + +*** config files hub + +#+BEGIN_SRC d :tangle ../src/sdp/ao_read_config_files.d +/+ + ++/ +template SiSUconfigSDLangHub() { + mixin SiSUconfigIn; + mixin SiSUconfigSDLang; + struct ConfigHub { + <<ao_config_file_sdlang_hub>> } } #+END_SRC @@ -488,7 +568,7 @@ from 0~ read in as content # #+BEGIN_SRC d /+ ↓ read file +/ // auto conf = MarkupRaw(); -auto conf = Config(); +auto conf = ConfigIn(); auto configfile_content = conf.sourceConfig(fn_src); # #+END_SRC |