4 #ifndef LEXY_DSL_PARSE_TREE_NODE_HPP_INCLUDED
5 #define LEXY_DSL_PARSE_TREE_NODE_HPP_INCLUDED
10 #if !LEXY_EXPERIMENTAL
11 # error "lexy::dsl::tnode/pnode are experimental"
17 template <
typename Derived>
20 template <
typename Derived,
typename R>
23 template <
typename NextParser>
26 template <
typename Context,
typename ChildReader,
typename Reader,
typename... Args>
28 bool& rule_succeded, Reader& reader, Args&&... args)
34 auto begin = child_reader.position();
35 auto end = reader.position();
47 template <
typename NextParser,
typename Context,
typename Reader,
typename... Args>
49 typename Reader::marker
end, Args&&... args)
51 auto child_reader = Derived::node_child_reader(reader);
56 if (
auto rule_succeded =
false;
71 template <
typename Reader>
74 typename Reader::marker
end;
76 constexpr
bool try_parse(
const void*,
const Reader& reader)
79 auto result = parser.try_parse(reader);
84 template <
typename Context>
88 template <
typename NextParser,
typename Context,
typename... Args>
91 return _parse_rule<NextParser>(context, reader,
end,
LEXY_FWD(args)...);
95 template <
typename NextParser>
98 template <
typename Context,
typename Reader,
typename... Args>
102 if (!parser.try_parse(reader))
104 LEXY_ASSERT(parser.end.position() == reader.position(),
"impl should be LL(1)");
105 parser.report_error(context, reader);
109 return _parse_rule<NextParser>(context, reader, parser.end,
LEXY_FWD(args)...);
114 template <
typename Derived>
115 struct _n : token_base<Derived>
117 template <
typename Reader>
120 typename Reader::marker
end;
122 constexpr
explicit tp(
const Reader& reader) :
end(reader.current()) {}
126 if constexpr (lexy::is_node_encoding<typename Reader::encoding>)
132 end = reader.current();
139 return std::false_type{};
143 template <
typename Context>
146 constexpr
auto name = Derived::node_kind_name();
153 template <
typename Rule>
168 return "expected token end";
191 template <
typename Reader>
194 return reader.lexeme_reader();
205 constexpr
auto token_kind_of<lexy::dsl::_tn<Kind>> = Kind;
215 return "expected production end";
222 template <
typename Production>
225 static_assert(lexy::is_production<Production>);
234 return lexy::production_name<Production>();
239 template <
typename Reader>
242 return reader.child_reader();
246 template <
typename Production>
250 #endif // LEXY_DSL_PARSE_TREE_NODE_HPP_INCLUDED