From 897653bcc510a3b6eab9861d518c645fe066b9c3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 26 Jan 2017 13:44:44 -0500 Subject: regex template, made more uniform --- org/ao_abstract_doc_source.org | 15 +++-------- org/ao_conf_make_meta.org | 4 +-- org/ao_defaults.org | 56 +++++++++++++++++++++--------------------- org/ao_output_debugs.org | 2 +- org/ao_read_source_files.org | 3 --- org/sdp.org | 2 +- 6 files changed, 36 insertions(+), 46 deletions(-) diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org index a7d3d84..a2673fa 100644 --- a/org/ao_abstract_doc_source.org +++ b/org/ao_abstract_doc_source.org @@ -158,10 +158,7 @@ Process markup document, create document abstraction. #+name: abs_imports #+BEGIN_SRC d -import - ao_defaults, // sdp/ao_defaults.d - ao_object_setter, // sdp/ao_object_setter.d - ao_rgx; // sdp/ao_rgx.d +import ao_object_setter; #+END_SRC *** mixins :mixins: @@ -170,6 +167,7 @@ import #+BEGIN_SRC d mixin ObjectSetter; mixin InternalMarkup; +mixin SiSUrgxInit; #+END_SRC *** initialize :initialize: @@ -177,7 +175,6 @@ mixin InternalMarkup; #+name: abs_init_struct #+BEGIN_SRC d /+ initialize +/ -auto rgx = Rgx(); ObjGenericComposite[][string] the_table_of_contents_section; ObjGenericComposite[] the_document_head_section, the_document_body_section, the_bibliography_section, the_glossary_section, the_blurb_section; ObjGenericComposite[] the_dom_tail_section; @@ -3787,7 +3784,6 @@ struct ObjInlineMarkupMunge { } } body { - auto rgx = Rgx(); obj_txt["munge"]=obj_txt_in; obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.para_attribs, ""); obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.obj_cite_number_off_all, ""); @@ -3807,7 +3803,6 @@ struct ObjInlineMarkupMunge { } } body { - auto rgx = Rgx(); obj_txt["munge"]=obj_txt_in; obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading, ""); obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.obj_cite_number_off_all, ""); @@ -3912,6 +3907,7 @@ struct ObjInlineMarkupMunge { #+name: ao_emitters_obj_inline_markup #+BEGIN_SRC d struct ObjInlineMarkup { + auto rgx = Rgx(); auto munge = ObjInlineMarkupMunge(); string[string] obj_txt; #+END_SRC @@ -4494,7 +4490,6 @@ struct ObjAttributes { } } body { - auto rgx = Rgx(); if (matchFirst(obj_txt_in, rgx.para_bullet)) { _obj_attributes =" \"bullet\": \"true\"," ~ " \"indent_hang\": 0," @@ -5383,6 +5378,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(); #+END_SRC ***** TODO node metadata emitter @@ -5406,7 +5402,6 @@ struct NodeStructureMetadata { static assert(is(typeof(ptr_) == int)); static assert(is(typeof(is_) == string)); } - auto rgx = Rgx(); assert(is_ != "heading"); assert(to!int(obj_cite_number_) >= 0); } @@ -5481,7 +5476,6 @@ struct NodeStructureMetadata { static assert(is(typeof(is_) == string)); static assert(is(typeof(html_segnames_ptr) == int)); } - auto rgx = Rgx(); assert(is_ == "heading"); assert(to!int(obj_cite_number_) >= 0); assert( @@ -5495,7 +5489,6 @@ struct NodeStructureMetadata { } } body { - auto rgx = Rgx(); int obj_cite_number = to!int(obj_cite_number_); switch (to!int(lev_markup_number)) { // switch (to!string(lv)) { case 0: diff --git a/org/ao_conf_make_meta.org b/org/ao_conf_make_meta.org index df6d456..4205af7 100644 --- a/org/ao_conf_make_meta.org +++ b/org/ao_conf_make_meta.org @@ -75,7 +75,7 @@ template SiSUheaderExtractNative() { struct HeaderDocMetadataAndMakeNativeToAA { mixin SiSUregisters; mixin SiSUrgxInitFlags; - mixin RgxInit; + mixin SiSUrgxInit; auto rgx = Rgx(); enum State { off, on } string hm, hs; @@ -98,7 +98,7 @@ template SiSUheaderExtractSDLang() { ao_rgx; struct HeaderExtractSDL { mixin SiSUregisters; - mixin RgxInit; + mixin SiSUrgxInit; auto rgx = Rgx(); <> } diff --git a/org/ao_defaults.org b/org/ao_defaults.org index e54d360..b46b2ad 100644 --- a/org/ao_defaults.org +++ b/org/ao_defaults.org @@ -14,7 +14,7 @@ [[./sdp.org][sdp]] [[./][org/]] * 0. Code Skeleton / Outline / Structure (tangles) :tangle: -** 1. defaults: :ao_defaults.d: +** 1. defaults: :ao_defaults: #+name: tangle_ao_defaults #+BEGIN_SRC d :tangle ../src/sdp/ao_defaults.d @@ -24,14 +24,14 @@ <> #+END_SRC -** 2. rgx: :ao_rgx.d: +** 2. rgx: :ao_rgx: #+name: tangle_ao_rgx #+BEGIN_SRC d :tangle ../src/sdp/ao_rgx.d /++ regex: regular expressions used in sisu document parser +/ -template RgxInit() { +template SiSUrgxInit() { struct Rgx { mixin SiSUlanguageCodes; <> @@ -41,7 +41,7 @@ template RgxInit() { * 1. default templates :template:defaults: [[./sdp.org][sdp]] [[./][org/]] -** template: settings metadata associative array indexes :settings: +** template: settings metadata associative array indexes :settings: #+name: ao_defaults_templates #+BEGIN_SRC d @@ -190,7 +190,7 @@ template SiSUregisters() { } #+END_SRC -** template: metadata associative array indexes :header: +** template: metadata associative array indexes :header: #+name: ao_defaults_templates #+BEGIN_SRC d @@ -462,7 +462,7 @@ template SiSUlanguageCodes() { } #+END_SRC -** template: flags regex initialize :regex_flags: +** template: flags regex initialize :regex_flags: #+name: ao_defaults_templates #+BEGIN_SRC d @@ -554,7 +554,7 @@ template SiSUnode() { } #+END_SRC -** template: bibliography :biblio: +** template: bibliography :biblio: #+name: ao_defaults_templates #+BEGIN_SRC d @@ -699,7 +699,7 @@ template SiSUpaths() { } #+END_SRC -** template: internal markup :markup: +** template: internal markup :markup: #+name: ao_defaults_templates #+BEGIN_SRC d @@ -734,7 +734,7 @@ http://dlang.org/phobos/std_regex.html - Regex!char (wchar/dchar) that contains a pattern in the form of compiled bytecode. - StaticRegex!char (wchar/dchar) that contains a pattern in the form of compiled native machine code. -** misc :misc: +** misc :misc: #+name: ao_rgx #+BEGIN_SRC d @@ -773,7 +773,7 @@ static src_fn_find_inserts = ctRegex!(`^(?P[a-z static insert_src_fn_ssi_or_sst = ctRegex!(`^<<\s*(?P[a-zA-Z0-9._-]+/)*(?P[a-zA-Z0-9._-]+[.]ss[ti])$`); #+END_SRC -** comments :comment: +** comments :comment: #+name: ao_rgx #+BEGIN_SRC d @@ -782,7 +782,7 @@ static comment = ctRegex!(`^%+ `); static comments = ctRegex!(`^%+ |^%+$`); #+END_SRC -** native header :native:header: +** native header :native:header: #+name: ao_rgx #+BEGIN_SRC d @@ -801,7 +801,7 @@ static variable_doc_author = ctRegex!(`@author|@creat static raw_author_munge = ctRegex!(`(\S.+?),\s+(.+)`,"i"); #+END_SRC -** subheader :native:subheader: +** subheader :native:subheader: #+name: ao_rgx #+BEGIN_SRC d @@ -818,7 +818,7 @@ static native_subhead_publisher = ctRegex!(`^(?:name)$`, " static native_subhead_make = ctRegex!(`^(?:cover_image|home_button_image|home_button_text|footer|headings|num_top|num_depth|breaks|substitute|bold|italics|emphasis|texpdf_font|css)$`, "m"); #+END_SRC -** heading & paragraph operators :paragraph:operator: +** heading & paragraph operators :paragraph:operator: #+name: ao_rgx #+BEGIN_SRC d @@ -849,7 +849,7 @@ static para_indent_hang = ctRegex!(`^_([0-9])_([0- static para_attribs = ctRegex!(`^_(([0-9])(_([0-9]))?|_([1-9])?[*]) `); #+END_SRC -** blocked markup :block:tic: +** blocked markup :block:tic: #+name: ao_rgx #+BEGIN_SRC d @@ -858,7 +858,7 @@ static block_open = ctRegex!("^((code([.][a- static block_poem_open = ctRegex!("^((poem[{].*?$)|`{3} poem)"); #+END_SRC -** blocked markup tics :block:tic: +** blocked markup tics :block:tic: #+name: ao_rgx #+BEGIN_SRC d @@ -873,7 +873,7 @@ static block_tic_table_open = ctRegex!("^`{3} (table)" static block_tic_close = ctRegex!("^(`{3})$","m"); #+END_SRC -** blocked markup curly :block:curly: +** blocked markup curly :block:curly: #+name: ao_rgx #+BEGIN_SRC d @@ -893,7 +893,7 @@ static block_curly_table_open = ctRegex!(`^(table[{].*?$ static block_curly_table_close = ctRegex!(`^([}]table)`); #+END_SRC -** inline markup font face mod :inline:font:face: +** inline markup font face mod :inline:font:face: #+name: ao_rgx #+BEGIN_SRC d @@ -908,7 +908,7 @@ static inline_insert = ctRegex!(`\+\{(?P. static inline_mono = ctRegex!(`#\{(?P.+?)\}#`); #+END_SRC -** inline markup footnotes endnotes :inline:footnote: +** inline markup footnotes endnotes :inline:footnote: #+name: ao_rgx #+BEGIN_SRC d @@ -931,7 +931,7 @@ static inline_text_and_note_curly = ctRegex!(`(?P.+?)( static note_ref = ctRegex!(`^\S+?noteref_([0-9]+)`, "mg"); // {^{73.}^}#noteref_73 #+END_SRC -** inline (internal program) markup footnotes endnotes :inline:footnote: +** inline (internal program) markup footnotes endnotes :inline:footnote: #+name: ao_rgx #+BEGIN_SRC d @@ -963,7 +963,7 @@ static inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(.+?) static inline_a_url = ctRegex!(`(┤)(\S+?)(├)`, "mg"); #+END_SRC -** inline markup book index :inline:bookindex: +** inline markup book index :inline:bookindex: #+name: ao_rgx #+BEGIN_SRC d @@ -973,7 +973,7 @@ static book_index_open = ctRegex!(`^=\{\s*([^}]+? static book_index_close = ctRegex!(`^(.*?)\}$`, "m"); // strip #+END_SRC -** no obj_cite_number object :ocn:off:object: +** no obj_cite_number object :ocn:off:object: #+name: ao_rgx #+BEGIN_SRC d @@ -983,7 +983,7 @@ static obj_cite_number_off_dh = ctRegex!(`-#$`, "m"); static obj_cite_number_off_all = ctRegex!(`[~-]#$`, "m"); #+END_SRC -** no obj_cite_number block :ocn:off:block: +** no obj_cite_number block :ocn:off:block: #+name: ao_rgx #+BEGIN_SRC d @@ -994,7 +994,7 @@ static obj_cite_number_off_block_close = ctRegex!(`^--\+#$`); static obj_cite_number_block_marks = ctRegex!(`^--[+~-]#$`); #+END_SRC -** ignore outside code blocks :block:code: +** ignore outside code blocks :block:code: #+name: ao_rgx #+BEGIN_SRC d @@ -1002,7 +1002,7 @@ static obj_cite_number_block_marks = ctRegex!(`^--[+~-]#$`); static skip_from_regular_parse = ctRegex!(`^(--[+~-]#|-[\\]{2}-|=[.\\]{2}=)$`); // not structural info #+END_SRC -** line & page breaks :break: +** line & page breaks :break: #+name: ao_rgx #+BEGIN_SRC d @@ -1015,7 +1015,7 @@ static break_string = ctRegex!(`』`); static parent = ctRegex!(`([0-7]):([0-9]+)`); #+END_SRC -** json :json: +** json :json: #+name: ao_rgx #+BEGIN_SRC d @@ -1023,7 +1023,7 @@ static parent = ctRegex!(`([0-7]):([0-9] static tailing_comma = ctRegex!(`,$`, "m"); #+END_SRC -** biblio tags :biblio:tags: +** biblio tags :biblio:tags: #+name: ao_rgx #+BEGIN_SRC d @@ -1032,7 +1032,7 @@ static biblio_tags = ctRegex!(`^(is|au|author static biblio_abbreviations = ctRegex!(`^(au|ed|ti|lng|jo|vol|edn|yr|pl|pb|pub|pg|pgs|sn)$`); #+END_SRC -** bookindex split :bookindex:split: +** bookindex split :bookindex:split: #+name: ao_rgx #+BEGIN_SRC d @@ -1043,7 +1043,7 @@ static bi_sub_terms_plus_obj_cite_number_offset_split = ctRegex!(`\s*\|\s*`); static bi_term_and_obj_cite_numbers_match = ctRegex!(`^(.+?)\+(\d+)`); #+END_SRC -* +set colors for terminal+ (unused) :colors:terminal: +* +set colors for terminal+ (unused) :colors:terminal: #+name: ao_ansi_colors #+BEGIN_SRC d diff --git a/org/ao_output_debugs.org b/org/ao_output_debugs.org index 43e1142..145a7a5 100644 --- a/org/ao_output_debugs.org +++ b/org/ao_output_debugs.org @@ -27,7 +27,7 @@ template SiSUoutputDebugs() { auto ref const S contents, auto ref T doc_matters, ) { - mixin RgxInit; + mixin SiSUrgxInit; mixin InternalMarkup; <> <> diff --git a/org/ao_read_source_files.org b/org/ao_read_source_files.org index 703ae9e..350ee19 100644 --- a/org/ao_read_source_files.org +++ b/org/ao_read_source_files.org @@ -80,9 +80,6 @@ template SiSUmarkupRaw() { std.stdio, std.utf, std.conv : to; - private import - ao_rgx; // ao_defaults.d - mixin RgxInit; auto rgx = Rgx(); struct MarkupRaw { final sourceContent(in string fn_src) { diff --git a/org/sdp.org b/org/sdp.org index f14c82e..8831171 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -181,13 +181,13 @@ mixin(import("version.txt")); #+NAME: mixin_pre_main #+BEGIN_SRC d mixin CompileTimeInfo; -mixin RgxInit; #+END_SRC ***** sdp "main" mixins :sdp: #+NAME: sdp_mixin #+BEGIN_SRC d +mixin SiSUrgxInit; mixin SiSUregisters; mixin SiSUheaderExtractHub; mixin SiSUheaderExtractSDLang; -- cgit v1.2.3