-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathqrqma_test.cpp
54 lines (44 loc) · 1.17 KB
/
qrqma_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "qrqma_test.h"
#include "qrqma/template.h"
#include "qrqma/tao/pegtl.hpp"
#include "qrqma/actions/actions.h"
namespace pegtl = tao::pegtl;
namespace qrqma_test
{
namespace {
void test(std::string const& content)
{
try {
qrqma::Template rendering{
content,
{
// to play with qrqma add symbols here
{"test", std::string{"Hello from compiling"}},
{"callable", qrqma::symbol::Function{[]() -> std::string {
return "output from a callable function";
}}},
}
};
std::cout << rendering(
// to play with qrqma add symbols here (for runtime defined symbols)
{
{"runtime_value", std::string{"Hello from rendering"}},
}
) << std::endl;
} catch (pegtl::parse_error const& error) {
std::cerr << error.what() << std::endl;
}
}
}
void qrqma_test()
{
if (template_text) {
test(*template_text);
}
if (template_file) {
auto content = qrqma::defaultLoader()(*template_file);
test(content);
}
}
sargp::Task qrqma_test_task{qrqma_test};
}