diff --git a/src/lib/parse.hpp b/src/lib/parse.hpp index 7eb8aa796..e8f75d310 100644 --- a/src/lib/parse.hpp +++ b/src/lib/parse.hpp @@ -90,14 +90,13 @@ namespace util { */ template struct Connex - : util::NonAssign { using PFun = FUN; PFun parse; using Result = typename _Fun::Ret::Result; - Connex (FUN&& pFun) + Connex (FUN pFun) : parse{move(pFun)} { } }; @@ -879,6 +878,15 @@ namespace util { } + /** Setup an assignable, recursive Syntax clause, initially empty */ + template + auto + expectResult() + { + return accept (Connex{std::function(StrView)>{}}); + } + + /** * Combinator: extend this Syntax clause by expecting a further sub-clause diff --git a/tests/library/parse-test.cpp b/tests/library/parse-test.cpp index 2073490f4..4738fe732 100644 --- a/tests/library/parse-test.cpp +++ b/tests/library/parse-test.cpp @@ -85,6 +85,7 @@ namespace test { acceptBracketed(); verify_modelBinding(); + verify_recursiveSyntax(); } @@ -616,6 +617,17 @@ namespace test { CHECK (syntax1e.parse("ham actor").getResult() == 8); CHECK (syntax1e.parse("con artist").getResult() == 9); } + + + /** @test definition of recursive Syntax clauses + */ + void + verify_recursiveSyntax() + { + auto recursive = expectResult(); + + string s1{"great ! great ! great"}; + } }; LAUNCHER (Parse_test, "unit common"); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index abd468065..6d32f1223 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -57643,6 +57643,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ FUN ≡ std::function & +

+ + +
+
+
+ + + + + + +

+ Connex-Definition +

+

+ erfüllt das bereits +

+ + +
+ + + + + + + + + + + + + + + + + + + + +

+ da viele Builder-Funktionen in ein neues Syntax-Objekt schieben +

+ + +
+ +
+
+ + + + + + + + + + + + + + + + + + +