diff options
author | Ralph Amissah <ralph@amissah.com> | 2017-07-27 04:38:26 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 |
commit | d56624bce222d870298d937e634fe01aef5c39e4 (patch) | |
tree | fda4da44a0fdddda9e99202ad69ebce9193c55ba /org/meta_abstraction.org | |
parent | meta_abstraction, mark some functions pure (diff) |
static, liberal use of keyword
Diffstat (limited to 'org/meta_abstraction.org')
-rw-r--r-- | org/meta_abstraction.org | 108 |
1 files changed, 55 insertions, 53 deletions
diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org index 678462b..cf86961 100644 --- a/org/meta_abstraction.org +++ b/org/meta_abstraction.org @@ -15,7 +15,7 @@ #+TAGS: assert(a) class(c) debug(d) mixin(m) sdp(s) tangle(T) template(t) WEB(W) noexport(n) [[./sdp.org][sdp]] [[./][org/]] -* 1. Document Abstraction :module:sdp:meta_metadoc_from_src: +* 1. Document Abstraction :module:sdp:metadoc_from_src: Process markup document, create document abstraction. ** 0. module template @@ -24,7 +24,7 @@ Process markup document, create document abstraction. /++ document abstraction: abstraction of sisu markup for downstream processing - meta_metadoc_from_src.d + metadoc_from_src.d +/ module sdp.meta.metadoc_from_src; template SiSUdocAbstraction() { @@ -41,7 +41,7 @@ template SiSUdocAbstraction() { Meta dochead_meta_aa, Opt opt_action, ) { - auto rgx = Rgx(); + static auto rgx = Rgx(); debug(asserts) { static assert(is(typeof(markup_sourcefile_content) == char[][])); static assert(is(typeof(dochead_make_aa) == string[string][string])); @@ -215,8 +215,8 @@ int verse_line, heading_ptr; int[string] indent; bool bullet = true; string content_non_header = "8"; -auto obj_im = ObjInlineMarkup(); -auto obj_att = ObjAttributes(); +static auto obj_im = ObjInlineMarkup(); +static auto obj_att = ObjAttributes(); /+ ocn +/ int obj_cite_number, obj_cite_number_; auto object_citation_number = OCNemitter(); @@ -513,8 +513,8 @@ the_table_of_contents_section = [ "seg": [toc_head], "scroll": [toc_head], ]; -auto mkup = InlineMarkup(); -auto munge = ObjInlineMarkupMunge(); +static auto mkup = InlineMarkup(); +static auto munge = ObjInlineMarkupMunge(); auto note_section = NotesSection(); auto bookindex_extract_hash = BookIndexNuggetHash(); string[][string] lev4_subtoc; @@ -560,7 +560,7 @@ debug(srclines) { #+name: abs_in_loop_body_00 #+BEGIN_SRC d if (!line.empty) { - _check_ocn_status_(line, type); + type = _check_ocn_status_(line, type); } #+END_SRC @@ -2307,7 +2307,7 @@ functions used in document abstraction #+name: abs_functions_object_reset #+BEGIN_SRC d -auto object_reset(O)(ref O an_object) { +static auto object_reset(O)(O an_object) { debug(asserts) { static assert(is(typeof(an_object) == string[string])); } @@ -2316,6 +2316,7 @@ auto object_reset(O)(ref O an_object) { an_object.remove("is"); an_object.remove("attrib"); an_object.remove("bookindex_nugget"); + return an_object; } #+END_SRC @@ -2337,7 +2338,7 @@ auto _common_reset_(L,O,T)( line_occur["para"] = State.off; type["heading"] = State.off; type["para"] = State.off; - object_reset(an_object); + an_object = object_reset(an_object); } #+END_SRC @@ -2345,15 +2346,15 @@ auto _common_reset_(L,O,T)( #+name: abs_functions_ocn_status #+BEGIN_SRC d -void _check_ocn_status_(L,T)( +static auto _check_ocn_status_(L,T)( L line, - return ref T type + T type ) { debug(asserts) { static assert(is(typeof(line) == char[])); static assert(is(typeof(type) == int[string])); } - auto rgx = Rgx(); + static auto rgx = Rgx(); if ((!line.empty) && (type["ocn_status_multi_obj"] == TriState.off)) { /+ not multi-line object, check whether obj_cite_number is on or turned off +/ if (line.matchFirst(rgx.obj_cite_number_block_marks)) { @@ -2393,6 +2394,7 @@ void _check_ocn_status_(L,T)( } } } + return type; } #+END_SRC @@ -2418,7 +2420,7 @@ void _start_block_(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d - auto rgx = Rgx(); + static auto rgx = Rgx(); string code_block_syntax = ""; bool code_block_numbered = false; if (auto m = line.matchFirst(rgx.block_curly_code_open)) { @@ -2604,7 +2606,7 @@ void _code_block_(L,O,T)( static assert(is(typeof(an_object) == string[string])); static assert(is(typeof(type) == int[string])); } - auto rgx = Rgx(); + static auto rgx = Rgx(); if (type["curly_code"] == TriState.on) { if (line.matchFirst(rgx.block_curly_code_close)) { debug(code) { // code (curly) close @@ -2745,7 +2747,7 @@ void _biblio_block_( ) { mixin SiSUbiblio; auto jsn = BibJsnStr(); - auto rgx = Rgx(); + static auto rgx = Rgx(); if (line.matchFirst(rgx.heading_biblio)) { type["biblio_section"] = TriState.on; type["blurb_section"] = State.off; @@ -2874,7 +2876,7 @@ void _quote_block_(L,O,T)( static assert(is(typeof(an_object) == string[string])); static assert(is(typeof(type) == int[string])); } - auto rgx = Rgx(); + static auto rgx = Rgx(); if (type["curly_quote"] == TriState.on) { if (line.matchFirst(rgx.block_curly_quote_close)) { debug(quote) { // quote (curly) close @@ -2926,7 +2928,7 @@ void _group_block_(L,O,T)( static assert(is(typeof(an_object) == string[string])); static assert(is(typeof(type) == int[string])); } - auto rgx = Rgx(); + static auto rgx = Rgx(); if (type["curly_group"] == State.on) { if (line.matchFirst(rgx.block_curly_group_close)) { debug(group) { @@ -2979,7 +2981,7 @@ void _block_block_(L,O,T)( static assert(is(typeof(an_object) == string[string])); static assert(is(typeof(type) == int[string])); } - auto rgx = Rgx(); + static auto rgx = Rgx(); if (type["curly_block"] == TriState.on) { if (line.matchFirst(rgx.block_curly_block_close)) { debug(block) { // block (curly) close @@ -3036,7 +3038,7 @@ void _poem_block_(L,O,T,C,N,Ma)( static assert(is(typeof(obj_cite_number_poem) == string[string])); static assert(is(typeof(dochead_make_aa) == string[string][string])); } - auto rgx = Rgx(); + static auto rgx = Rgx(); if (type["curly_poem"] == TriState.on) { if (line.matchFirst(rgx.block_curly_poem_close)) { if (an_object_key in an_object @@ -3272,7 +3274,7 @@ void _table_block_(L,O,T,Ma)( static assert(is(typeof(an_object) == string[string])); static assert(is(typeof(type) == int[string])); } - auto rgx = Rgx(); + static auto rgx = Rgx(); if (type["curly_table"] == TriState.on) { if (line.matchFirst(rgx.block_curly_table_close)) { debug(table) { // table (curly) close @@ -3695,7 +3697,7 @@ auto _book_index_(L,I,O,T,B)( static assert(is(typeof(type) == int[string])); static assert(is(typeof(opt_action) == bool[string])); } - auto rgx = Rgx(); + static auto rgx = Rgx(); if (auto m = line.match(rgx.book_index)) { /+ match book_index +/ debug(bookindexmatch) { // book index @@ -3761,7 +3763,7 @@ auto _heading_found_(L,X,H,R,T)( static assert(is(typeof(heading_match_rgx) == Regex!(char)[string])); static assert(is(typeof(type) == int[string])); } - auto rgx = Rgx(); + static auto rgx = Rgx(); if ((dochead_make_identify_unmarked_headings.length > 2) && (type["make_headings"] == State.off)) { /+ headings found +/ @@ -3933,7 +3935,7 @@ auto _heading_matched_(L,C,O,K,Lv,Lc,T,Me)( static assert(is(typeof(type) == int[string])); static assert(is(typeof(dochead_meta_aa) == string[string][string])); } - auto rgx = Rgx(); + static auto rgx = Rgx(); if (auto m = line.match(rgx.heading)) { /+ heading match +/ type["heading"] = State.on; @@ -4092,7 +4094,7 @@ void _para_match_(L,O,K,I,B,T,C)( static assert(is(typeof(type) == int[string])); static assert(is(typeof(line_occur) == int[string])); } - auto rgx = Rgx(); + static auto rgx = Rgx(); if (line_occur["para"] == State.off) { line = font_faces_line(line); /+ para matches +/ @@ -4142,9 +4144,9 @@ void _para_match_(L,O,K,I,B,T,C)( #+name: abs_functions_para #+BEGIN_SRC d auto font_faces_line(T)( - return ref T textline, + T textline, ) { - auto rgx = Rgx(); + static auto rgx = Rgx(); if (textline.match(rgx.inline_faces_line)) { textline = (textline) .replaceFirst(rgx.inline_emphasis_line, ("*{$1}*$2")) @@ -4173,7 +4175,7 @@ auto table_instructions(O,H)( return ref O table_object, return ref H table_head, ) { - auto rgx = Rgx(); + static auto rgx = Rgx(); table_object.use = "body"; table_object.is_of = "block"; table_object.is_a = "table"; @@ -4201,8 +4203,8 @@ auto table_array_munge(O,T)( return ref O table_object, return ref T table_array, ) { - auto rgx = Rgx(); - auto mng = InlineMarkup(); + static auto rgx = Rgx(); + static auto mng = InlineMarkup(); string _table_substantive; ulong col_num; ulong col_num_; @@ -4331,8 +4333,8 @@ auto table_array_munge_open_close(O,T)( return ref O table_object, return ref T table_array, ) { - auto rgx = Rgx(); - auto mng = InlineMarkup(); + static auto rgx = Rgx(); + static auto mng = InlineMarkup(); string _table_substantive; foreach(row; table_array) { foreach(col; row) { @@ -4356,8 +4358,8 @@ auto table_substantive_munge(O,T)( return ref O table_object, return ref T table_substantive, ) { - auto rgx = Rgx(); - auto munge = ObjInlineMarkupMunge(); + static auto rgx = Rgx(); + static auto munge = ObjInlineMarkupMunge(); string[] _table_rows = (table_substantive).split(rgx.table_row_delimiter); string[] _table_cols; string[][] _table; @@ -4378,8 +4380,8 @@ auto table_substantive_munge_special(O,T)( return ref O table_object, return ref T table_substantive, ) { - auto rgx = Rgx(); - auto munge = ObjInlineMarkupMunge(); + static auto rgx = Rgx(); + static auto munge = ObjInlineMarkupMunge(); string[] _table_rows = (table_substantive).split(rgx.table_row_delimiter_special); string[] _table_cols; string[][] _table; @@ -4424,13 +4426,13 @@ pure struct OCNemitter { #+name: meta_emitters_obj_inline_markup_munge #+BEGIN_SRC d -struct ObjInlineMarkupMunge { +static struct ObjInlineMarkupMunge { string[string] obj_txt; int n_foot, n_foot_reg, n_foot_sp_asterisk, n_foot_sp_plus; string asterisks_; string obj_txt_out, tail, note; - auto rgx = Rgx(); - auto mkup = InlineMarkup(); + static auto rgx = Rgx(); + static auto mkup = InlineMarkup(); int stage_reset_note_numbers = true; private auto initialize_note_numbers() { n_foot = 0; @@ -4444,11 +4446,11 @@ struct ObjInlineMarkupMunge { #+name: meta_emitters_obj_inline_markup_munge #+BEGIN_SRC d - string url_links(Ot)(Ot obj_txt_in) { + static string url_links(Ot)(Ot obj_txt_in) { debug(asserts) { static assert(is(typeof(obj_txt_in) == string)); } - auto mng = InlineMarkup(); + static auto mng = InlineMarkup(); obj_txt_in = obj_txt_in.replaceAll(rgx.inline_mono, (mng.mono ~ "{$1}" ~ mng.mono)); /+ url matched +/ if (obj_txt_in.match(rgx.inline_url_generic)) { @@ -4853,9 +4855,9 @@ struct ObjInlineMarkupMunge { #+name: meta_emitters_obj_inline_markup #+BEGIN_SRC d -struct ObjInlineMarkup { - auto rgx = Rgx(); - auto munge = ObjInlineMarkupMunge(); +static struct ObjInlineMarkup { + static auto rgx = Rgx(); + static auto munge = ObjInlineMarkupMunge(); string[string] obj_txt; #+END_SRC @@ -4986,7 +4988,7 @@ struct ObjInlineMarkup { body { ObjGenericComposite comp_obj_toc; mixin InternalMarkup; - auto mkup = InlineMarkup(); + static auto mkup = InlineMarkup(); char[] heading_toc_ = (obj_["substantive"].dup.strip.to!(char[])).replaceAll(rgx.inline_notes_al, ""); heading_toc_ = _clean_heading_toc_(heading_toc_); auto attrib=""; @@ -5748,7 +5750,7 @@ struct BookIndexNuggetHash { } } body { - auto rgx = Rgx(); + static auto rgx = Rgx(); if (!bookindex_section.empty) { auto bi_main_terms_split_arr = bookindex_section.split(rgx.bi_main_terms_split); @@ -5845,8 +5847,8 @@ struct BookIndexReportIndent { #+BEGIN_SRC d struct BookIndexReportSection { int mkn, skn; - auto rgx = Rgx(); - auto munge = ObjInlineMarkupMunge(); + static auto rgx = Rgx(); + static auto munge = ObjInlineMarkupMunge(); #+END_SRC ****** bookindex write section @@ -5900,7 +5902,7 @@ struct BookIndexReportSection { } mixin SiSUnode; mixin InternalMarkup; - auto mkup = InlineMarkup(); + static auto mkup = InlineMarkup(); string type_is; string lev; int heading_lev_markup, heading_lev_collapsed; @@ -6062,7 +6064,7 @@ struct NotesSection { string[string] object_notes; int previous_count; int mkn; - auto rgx = Rgx(); + static auto rgx = Rgx(); #+END_SRC ***** { gather notes for endnote section struct open @@ -6090,8 +6092,8 @@ struct NotesSection { } body { mixin InternalMarkup; - auto mkup = InlineMarkup(); - auto munge = ObjInlineMarkupMunge(); + static auto mkup = InlineMarkup(); + static auto munge = ObjInlineMarkupMunge(); foreach( m; (contents_am[cntr].text).matchAll( @@ -6394,7 +6396,7 @@ struct NodeStructureMetadata { int lv, lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7; int obj_cite_number; int[string] p_; // p_ parent_ - auto rgx = Rgx(); + static auto rgx = Rgx(); #+END_SRC ***** node metadata emitter |