specs_lambdas.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. std::map<std::string,mstch::node> specs_lambdas {
  2. {"Interpolation", mstch::lambda{[](const std::string&) -> mstch::node {
  3. return std::string{"world"};
  4. }}},
  5. {"Interpolation - Expansion", mstch::lambda{[](const std::string&) -> mstch::node {
  6. return std::string{"{{planet}}"};
  7. }}},
  8. {"Interpolation - Alternate Delimiters", mstch::lambda{[](const std::string&) -> mstch::node {
  9. return std::string{"|planet| => {{planet}}"};
  10. }}},
  11. {"Interpolation - Multiple Calls", mstch::lambda{[](const std::string&) -> mstch::node {
  12. static int calls = 0; return ++calls;
  13. }}},
  14. {"Escaping", mstch::lambda{[](const std::string&) -> mstch::node {
  15. return std::string{">"};
  16. }}},
  17. {"Section", mstch::lambda{[](const std::string& txt) -> mstch::node {
  18. return std::string{(txt == "{{x}}") ? "yes" : "no"};
  19. }}},
  20. {"Section - Expansion", mstch::lambda{[](const std::string& txt) -> mstch::node {
  21. return txt + std::string{"{{planet}}"} + txt;
  22. }}},
  23. {"Section - Alternate Delimiters", mstch::lambda{[](const std::string& txt) -> mstch::node {
  24. return txt + std::string{"{{planet}} => |planet|"} + txt;
  25. }}},
  26. {"Section - Multiple Calls", mstch::lambda{[](const std::string& txt) -> mstch::node {
  27. return "__" + txt + "__";
  28. }}},
  29. {"Inverted Section", mstch::lambda{[](const std::string&) -> mstch::node {
  30. return false;
  31. }}}
  32. };