A community of enthusiasts has developed a custom DSL using macros, which works like do-notation from functional languages. Advanced preprocessor features are utilized. The presented project implements a new technique for parsing DSL, which may contribute to the creation of further DSLs in the C and C++ preprocessor. The code in the repository is written in C++23 and is open under the MIT license, while the technique can also be used in the C preprocessor. // Without DSL: auto result = bind(mx, [&](auto x) { return bind(my, [&](auto y) { return make_value(x, y); }); }); // With DSL: auto result = DO( LET x IS(mx); LET y IS(my); return make_value(x, y); );
Source: opennet.ru