Go to the documentation of this file.
4 #ifndef LEXY_EXT_PARSE_TREE_DOCTEST_HPP_INCLUDED
5 #define LEXY_EXT_PARSE_TREE_DOCTEST_HPP_INCLUDED
9 #include <doctest/doctest.h>
14 template <
typename TokenKind =
void>
27 template <
typename RootProduction,
typename = lexy::production_rule<RootProduction>>
31 template <
typename Iterator>
39 for (
auto iter =
begin; iter !=
end; ++iter)
46 else if (std::isprint(c))
48 char str[] = {char(c), 0};
54 auto size = std::snprintf(
buffer, 16,
"\\{%x}",
unsigned(c) % 0xFF);
62 template <
typename CharT>
71 template <
typename CharT>
76 template <
typename CharT>
81 template <
typename CharT>
86 template <
typename CharT>
100 _tree += doctest::String(name);
107 template <
typename Production,
typename = lexy::production_rule<Production>>
110 return production(lexy::production_name<Production>());
121 return expected.
_tree + doctest::String(
" ");
124 template <
typename Reader,
typename MemoryResource>
129 = doctest::StringMaker<lexy::parse_tree<Reader, TokenKind, MemoryResource>>;
130 return toString(desc) == string_maker::convert(tree);
132 template <
typename Reader,
typename MemoryResource>
137 = doctest::StringMaker<lexy::parse_tree<Reader, TokenKind, MemoryResource>>;
138 return toString(desc) == string_maker::convert(tree);
150 for (
auto i = 0; i !=
_level - 1; ++i)
163 template <
typename Reader,
typename TokenKind,
typename MemoryResource>
172 for (
auto [event, node] : tree.
traverse())
183 auto token = node.token();
189 return toString(builder);
194 #endif // LEXY_EXT_PARSE_TREE_DOCTEST_HPP_INCLUDED
constexpr auto size(const C &c) -> decltype(c.size())
traverse_range traverse(const node &n) const noexcept
constexpr auto token(Rule)
Turns the arbitrary rule into a token by matching it without producing any values.
parse_tree_desc(RootProduction)
parse_tree_desc & literal(const CharT *spelling)
friend doctest::String toString(const parse_tree_desc &expected)
@ exit
We're visiting a production node after all its children.
friend bool operator==(const lexy::parse_tree< Reader, TokenKind, MemoryResource > &tree, const parse_tree_desc &desc)
friend bool operator==(const parse_tree_desc &desc, const lexy::parse_tree< Reader, TokenKind, MemoryResource > &tree)
parse_tree_desc & token(lexy::token_kind< TokenKind > kind, Iterator begin, Iterator end)
constexpr auto end(const C &c) -> decltype(c.end())
static String convert(const parse_tree &tree)
parse_tree_desc & production(const char *name)
parse_tree_desc(const char *root_name)
parse_tree_desc & digits(const CharT *spelling)
What sort of token it is.
buffer(const CharT *, const CharT *) -> buffer< deduce_encoding< CharT >>
parse_tree_desc & production(Production)
@ leaf
We're visiting a token.
parse_tree_desc & token(lexy::token_kind< TokenKind > kind, const CharT *spelling)
constexpr auto begin(const C &c) -> decltype(c.begin())
constexpr const char * name() const noexcept
parse_tree_desc & whitespace(const CharT *spelling)
const LEXY_CONSTEVAL char * production_name()
parse_tree_desc & finish()
@ enter
We're visiting a production node before all its children.
#define LEXY_ASSERT(Expr, Msg)
parse_tree_desc & token(const CharT *spelling)