Library: draft the interpretation of a compiled TextTemplate

will use an iteration-pipeline, based on the »State Core« concept
This commit is contained in:
Fischlurch 2024-03-19 15:53:35 +01:00
parent 5881b014fe
commit d2dcf6c163
2 changed files with 56 additions and 5 deletions

View file

@ -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<class IT>
string instantiate (IT&);
};
template<class BIND>
struct Instance
/** Binding to a specific data source.
* @note requires partial specialisation */
template<class DAT, typename SEL=void>
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<Action>;
using PipeTODO = std::vector<string>;
using InstanceIter = decltype (explore (std::declval<PipeTODO const&>()));

View file

@ -112670,6 +112670,12 @@ std::cout &lt;&lt; tmpl.render({&quot;what&quot;, &quot;World&quot;}) &lt;&lt; s
<node CREATED="1710809343987" ID="ID_1483329962" MODIFIED="1710809347034" TEXT="enum Code"/>
<node CREATED="1710809347760" ID="ID_1225629738" MODIFIED="1710809361714" TEXT="struct ParseCtx"/>
<node CREATED="1710810113497" ID="ID_1468035459" MODIFIED="1710810122668" TEXT="struct Action"/>
<node CREATED="1710856965721" ID="ID_866140063" MODIFIED="1710856975344" TEXT="ActionSeq = vector&lt;Action&gt;">
<node BACKGROUND_COLOR="#f8f1cb" COLOR="#a50125" CREATED="1710856991002" ID="ID_1648914815" MODIFIED="1710856998346" TEXT="Referenzen sind nicht stabil">
<icon BUILTIN="messagebox_warning"/>
</node>
<node CREATED="1710857036363" ID="ID_1655406963" MODIFIED="1710857070451" TEXT="kein Problem &#x27f8; alle Verweise funktionieren per Index-Nr."/>
</node>
<node CREATED="1710809364702" ID="ID_1039397469" MODIFIED="1710809374320" TEXT="struct Instance&lt;Binding&gt;"/>
</node>
</node>
@ -112815,6 +112821,35 @@ std::cout &lt;&lt; tmpl.render({&quot;what&quot;, &quot;World&quot;}) &lt;&lt; s
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1710856691780" ID="ID_763640380" MODIFIED="1710856698164" TEXT="Rahmen schaffen">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1710856716918" ID="ID_1752947576" MODIFIED="1710856723204" TEXT="r&#xfc;ckw&#xe4;rts vorgehen">
<icon BUILTIN="idea"/>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1710856729291" ID="ID_1875406462" MODIFIED="1710859944223" TEXT="die Instantiierung erfolgt lazy &#x27f9; Iterator-Pipeline">
<icon BUILTIN="pencil"/>
<node CREATED="1710856916531" ID="ID_1047340326" MODIFIED="1710856926342" TEXT="die ActionSeq konsumieren"/>
<node CREATED="1710857877562" ID="ID_707601175" MODIFIED="1710857911451" TEXT="Instantiierungs-Prozessor : function-mapping"/>
<node CREATED="1710858136177" ID="ID_1016066994" MODIFIED="1710858673982" TEXT="logische Signatur des Einzelschrits: (Action, Binding, Ctx) &#x27fc; string"/>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1710858917164" ID="ID_1301011429" MODIFIED="1710859941873" TEXT="praktischer Ansatz: IterableDecorator &#xfc;ber DataBind">
<icon BUILTIN="pencil"/>
<node CREATED="1710859059558" ID="ID_878052078" MODIFIED="1710859508605" TEXT="das ist das konkrete Binding">
<node CREATED="1710859078771" ID="ID_283747990" MODIFIED="1710859082314" TEXT="ist move-only"/>
<node CREATED="1710859083131" ID="ID_1103676674" MODIFIED="1710859102540" TEXT="const- referenziert die Daten"/>
<node CREATED="1710859106953" ID="ID_1570382274" MODIFIED="1710859128336" TEXT="implementiert das Binding-Concept"/>
</node>
<node CREATED="1710859515737" ID="ID_1401350564" MODIFIED="1710859521900" TEXT="enth&#xe4;lt eine DataSrc">
<node CREATED="1710859523200" ID="ID_1772496628" MODIFIED="1710859542793" TEXT="diese referenziert die Daten"/>
<node CREATED="1710859544029" ID="ID_1522505977" MODIFIED="1710859550400" TEXT="ist aber assignable"/>
<node CREATED="1710859551122" ID="ID_602535289" MODIFIED="1710859562631" TEXT="und implementiert die Binding-Funktionalit&#xe4;t"/>
</node>
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1710859064221" ID="ID_190332829" MODIFIED="1710859956662" TEXT="h&#xe4;lt au&#xdf;erdem einen DataSrc::Iter">
<icon BUILTIN="flag-pink"/>
</node>
</node>
</node>
<node CREATED="1710856784967" ID="ID_201927694" MODIFIED="1710856798759" TEXT="Parsing soll eager sein (wegen Syntax-Fehlern)"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1710793352301" ID="ID_1691061928" MODIFIED="1710793355254" TEXT="Bindings">
<icon BUILTIN="flag-yellow"/>