From d2dcf6c16301b91b320b28a1a917a2da117cfc05 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 19 Mar 2024 15:53:35 +0100 Subject: [PATCH] Library: draft the interpretation of a compiled TextTemplate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit will use an iteration-pipeline, based on the »State Core« concept --- src/lib/text-template.hpp | 26 +++++++++++++++++++++----- wiki/thinkPad.ichthyo.mm | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/src/lib/text-template.hpp b/src/lib/text-template.hpp index 6529229af..ef4307298 100644 --- a/src/lib/text-template.hpp +++ b/src/lib/text-template.hpp @@ -75,23 +75,39 @@ namespace lib { TEXT, KEY, COND, JUMP, ITER, LOOP }; + /** cross-references by index number */ + using Idx = size_t; + struct ParseCtx { Clause clause; + Idx begin{0}; + Idx after{0}; }; struct Action { - Code code; - string val; + Code code{TEXT}; + string val{""}; + Idx refIDX{0}; + + template + string instantiate (IT&); }; - template - struct Instance + /** Binding to a specific data source. + * @note requires partial specialisation */ + template + struct InstanceCore { - + static_assert (not sizeof(DAT), + "unable to bind this data source " + "for TextTemplate instantiation"); }; + /** the text template is compiled into a sequence of Actions */ + using ActionSeq = std::vector; + using PipeTODO = std::vector; using InstanceIter = decltype (explore (std::declval())); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 8ce262d16..4a9bc919f 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -112670,6 +112670,12 @@ std::cout << tmpl.render({"what", "World"}) << s + + + + + + @@ -112815,6 +112821,35 @@ std::cout << tmpl.render({"what", "World"}) << s + + + + + + + + + + + + + + + + + + + + + + + + + + + + +