4 #ifndef LEXY_DSL_IDENTIFIER_HPP_INCLUDED
5 #define LEXY_DSL_IDENTIFIER_HPP_INCLUDED
21 return "reserved identifier";
28 template <
typename Id,
typename CharT, CharT... C>
30 template <
typename Literal,
template <
typename>
typename CaseFolding>
33 template <
typename Leading,
typename Trailing>
36 template <
typename Reader>
39 typename Reader::marker
end;
41 constexpr
explicit tp(
const Reader& reader) :
end(reader.current()) {}
45 static_assert(lexy::is_char_encoding<typename Reader::encoding>);
54 if constexpr (lexy::_detail::is_swar_reader<Reader>)
57 while (Trailing{}.template char_class_match_swar<typename Reader::encoding>(
66 end = reader.current();
70 template <
typename Context>
71 constexpr
void report_error(Context& context,
const Reader& reader)
73 Leading::template char_class_report_error<Reader>(context, reader.position());
78 template <
typename Set>
81 template <
typename Input>
84 auto reader = input.reader();
89 template <
typename Set>
92 template <
typename Input>
95 auto reader = input.reader();
99 template <
typename Set>
102 template <
typename Input>
105 auto reader = input.reader();
119 template <
typename Set>
122 template <
typename Input>
125 auto reader = input.reader();
141 template <
typename Leading,
typename Trailing,
typename... ReservedPredicate>
144 template <
typename NextParser>
147 template <
typename Context,
typename Reader,
typename... Args>
151 auto begin = reader.position();
152 if (!
pattern().token_parse(context, reader))
154 auto end = reader.position();
158 if ((ReservedPredicate::is_reserved(input) || ...))
172 template <
typename Reader>
175 typename Reader::marker
end;
177 constexpr
bool try_parse(
const void*,
const Reader& reader)
181 if (!parser.try_parse(reader))
186 [[maybe_unused]]
auto input
188 return !(ReservedPredicate::is_reserved(input) || ...);
191 template <
typename Context>
195 template <
typename NextParser,
typename Context,
typename... Args>
198 auto begin = reader.position();
209 template <
typename R>
212 static_assert(lexy::is_literal_rule<R> || lexy::is_literal_set_rule<R>);
215 template <
typename Id,
typename CharT, CharT... C>
218 static_assert(std::is_same_v<decltype(Id{}.pattern()), decltype(
pattern())>,
219 "must not reserve keywords from another identifier");
221 return _lit<CharT, C...>{};
223 template <
typename Id,
typename CharT, CharT... C,
template <
typename>
typename CaseFolding>
226 static_assert(std::is_same_v<decltype(Id{}.pattern()), decltype(
pattern())>,
227 "must not reserve keywords from another identifier");
229 return _cfl<
_lit<CharT, C...>, CaseFolding>{};
234 template <
typename... R>
237 static_assert(
sizeof...(R) > 0);
239 return _id<Leading, Trailing, ReservedPredicate...,
_idrp<decltype(set)>>{};
243 template <
typename... R>
246 static_assert(
sizeof...(R) > 0);
248 return _id<Leading, Trailing, ReservedPredicate...,
_idpp<decltype(set)>>{};
252 template <
typename... R>
255 static_assert(
sizeof...(R) > 0);
257 return _id<Leading, Trailing, ReservedPredicate...,
_idcp<decltype(set)>>{};
261 template <
typename... R>
264 static_assert(
sizeof...(R) > 0);
266 return _id<Leading, Trailing, ReservedPredicate...,
_idsp<decltype(set)>>{};
289 template <
typename CharClass>
292 static_assert(lexy::is_char_class_rule<CharClass>);
298 template <
typename LeadingClass,
typename TrailingClass>
301 static_assert(lexy::is_char_class_rule<LeadingClass>
302 && lexy::is_char_class_rule<TrailingClass>);
309 template <
typename Leading,
typename Trailing>
316 template <
typename Id,
typename CharT, CharT... C>
317 struct _kw : token_base<_kw<Id, CharT, C...>>, _lit_base
327 template <
typename Encoding>
335 template <
typename Trie>
337 std::size_t char_class)
339 auto end = ((pos = trie.insert(pos, C)), ...);
340 trie.node_char_class[
end] = char_class;
344 template <
typename Reader>
347 typename Reader::marker
end;
349 constexpr
explicit tp(
const Reader& reader) :
end(reader.current()) {}
354 if (!lexy::_detail::match_literal<0, CharT, C...>(reader))
356 end = reader.current();
363 template <
typename Context>
370 auto begin = reader.position();
372 auto end = reader.position();
380 template <
typename Id>
382 template <
typename L,
typename T,
typename... R>
385 template <
typename CharT, CharT... C>
390 template <lexy::_detail::string_literal Str,
typename L,
typename T,
typename... R>
393 return lexy::_detail::to_type_string<_keyword<_id<L, T>>::template
get, Str>{};
396 template <
auto C,
typename L,
typename T,
typename... R>
403 #define LEXY_KEYWORD(Str, Id) \
404 LEXY_NTTP_STRING(::lexyd::_keyword<LEXY_DECAY_DECLTYPE(Id)>::template get, Str) {}
409 template <
typename Id,
typename CharT, CharT... C>
413 #endif // LEXY_DSL_IDENTIFIER_HPP_INCLUDED