literal.hpp
Go to the documentation of this file.
1 // Copyright (C) 2020-2024 Jonathan Müller and lexy contributors
2 // SPDX-License-Identifier: BSL-1.0
3 
4 #ifndef LEXY_DSL_LITERAL_HPP_INCLUDED
5 #define LEXY_DSL_LITERAL_HPP_INCLUDED
6 
11 #include <lexy/_detail/swar.hpp>
12 #include <lexy/dsl/base.hpp>
13 #include <lexy/dsl/token.hpp>
14 
15 //=== lit_matcher ===//
16 namespace lexy::_detail
17 {
18 template <std::size_t CurCharIndex, typename CharT, CharT... Cs, typename Reader>
19 constexpr auto match_literal(Reader& reader)
20 {
21  static_assert(lexy::is_char_encoding<typename Reader::encoding>);
22  using char_type = typename Reader::encoding::char_type;
23  if constexpr (CurCharIndex >= sizeof...(Cs))
24  {
25  (void)reader;
26  return std::true_type{};
27  }
28  // We only use SWAR if the reader supports it and we have enough to fill at least one.
29  else if constexpr (is_swar_reader<Reader> && sizeof...(Cs) >= swar_length<char_type>)
30  {
31  // Try and pack as many characters into a swar as possible, starting at the current
32  // index.
33  constexpr auto pack = swar_pack<CurCharIndex>(transcode_char<char_type>(Cs)...);
34 
35  // Do a single swar comparison.
36  if ((reader.peek_swar() & pack.mask) == pack.value)
37  {
38  reader.bump_swar(pack.count);
39 
40  // Recurse with the incremented index.
41  return bool(match_literal<CurCharIndex + pack.count, CharT, Cs...>(reader));
42  }
43  else
44  {
45  auto partial = swar_find_difference<CharT>(reader.peek_swar() & pack.mask, pack.value);
46  reader.bump_swar(partial);
47  return false;
48  }
49  }
50  else
51  {
52  static_assert(CurCharIndex == 0);
53 
54  // Compare each code unit, bump on success, cancel on failure.
55  return ((reader.peek() == transcode_int<typename Reader::encoding>(Cs)
56  ? (reader.bump(), true)
57  : false)
58  && ...);
59  }
60 }
61 } // namespace lexy::_detail
62 
63 //=== lit_trie ===//
64 namespace lexy::_detail
65 {
66 template <typename Encoding, template <typename> typename CaseFolding, std::size_t MaxCharCount,
67  typename... CharClasses>
68 struct lit_trie
69 {
70  using encoding = Encoding;
71  using char_type = typename Encoding::char_type;
72 
73  template <typename Reader>
74  using reader = CaseFolding<Reader>;
75 
76  static constexpr auto max_node_count = MaxCharCount + 1; // root node
77  static constexpr auto max_transition_count
78  = max_node_count == 1 ? 1 : max_node_count - 1; // it is a tree
79  static constexpr auto node_no_match = std::size_t(-1);
80 
81  std::size_t node_count;
82  std::size_t node_value[max_node_count];
83  // Index of a char class that must not match at the end.
84  // This is used for keywords.
86 
90 
94  {
96  node_char_class[0] = sizeof...(CharClasses);
97  }
98 
99  template <typename CharT>
100  LEXY_CONSTEVAL std::size_t insert(std::size_t from, CharT _c)
101  {
102  auto c = transcode_char<char_type>(_c);
103 
104  // We need to find a transition.
105  // In a tree, we're always having node_count - 1 transitions, so that's the upper bound.
106  // Everytime we add a transition from a node, its transition index is >= its node index.
107  // As such, we start looking at the node index.
108  for (auto i = from; i != node_count - 1; ++i)
109  {
110  if (transition_from[i] == from && transition_char[i] == c)
111  return transition_to[i];
112  }
113 
114  auto to = node_count;
116  node_char_class[to] = sizeof...(CharClasses);
117 
118  auto trans = node_count - 1;
119  transition_char[trans] = c;
120  transition_from[trans] = from; // trans >= from as from < node_count
121  transition_to[trans] = to;
122 
123  ++node_count;
124  return to;
125  }
126 
127  template <typename CharT, CharT... C>
128  LEXY_CONSTEVAL std::size_t insert(std::size_t pos, type_string<CharT, C...>)
129  {
130  return ((pos = insert(pos, C)), ...);
131  }
132 
133  LEXY_CONSTEVAL auto node_transitions(std::size_t node) const
134  {
135  struct
136  {
137  std::size_t length;
138  std::size_t index[max_transition_count];
139  } result{};
140 
141  // We need to consider the same range only.
142  for (auto i = node; i != node_count - 1; ++i)
143  if (transition_from[i] == node)
144  {
145  result.index[result.length] = i;
146  ++result.length;
147  }
148 
149  return result;
150  }
151 };
152 
153 template <typename... CharClasses>
155 {
156  template <typename Encoding, template <typename> typename CaseFolding, std::size_t N>
157  using trie_type = lit_trie<Encoding, CaseFolding, N, CharClasses...>;
158 
159  static constexpr auto size = sizeof...(CharClasses);
160 
161  template <typename... T>
162  constexpr auto operator+(char_class_list<T...>) const
163  {
164  return char_class_list<CharClasses..., T...>{};
165  }
166 };
167 
168 template <typename CurrentCaseFolding, typename... Literals>
170 template <>
172 {
173  template <typename Reader>
174  using case_folding = Reader;
175 };
176 template <typename CurrentCaseFolding>
177 struct _merge_case_folding<CurrentCaseFolding>
178 {
179  template <typename Reader>
180  using case_folding = typename CurrentCaseFolding::template reader<Reader>;
181 };
182 template <typename CurrentCaseFolding, typename H, typename... T>
183 struct _merge_case_folding<CurrentCaseFolding, H, T...>
184 : _merge_case_folding<std::conditional_t<std::is_void_v<CurrentCaseFolding>,
185  typename H::lit_case_folding, CurrentCaseFolding>,
186  T...>
187 {
188  static_assert(std::is_same_v<CurrentCaseFolding,
189  typename H::lit_case_folding> //
190  || std::is_void_v<CurrentCaseFolding>
191  || std::is_void_v<typename H::lit_case_folding>,
192  "cannot mix literals with different case foldings in a literal_set");
193 };
194 
195 template <typename Reader>
196 using lit_no_case_fold = Reader;
197 
198 template <typename Encoding, typename... Literals>
200 {
201  constexpr auto max_char_count = (0 + ... + Literals::lit_max_char_count);
202 
203  // Merge all mentioned character classes in a single list.
204  constexpr auto char_classes
205  = (lexy::_detail::char_class_list{} + ... + Literals::lit_char_classes);
206 
207  // Need to figure out case folding as well.
208  return typename decltype(char_classes)::template trie_type<
209  Encoding, _merge_case_folding<void, Literals...>::template case_folding, max_char_count>{};
210 }
211 template <typename Encoding, typename... Literals>
212 using lit_trie_for = decltype(make_empty_trie<Encoding, Literals...>());
213 
214 template <std::size_t CharClassIdx, bool, typename...>
216 {
217  template <typename Reader>
218  LEXY_FORCE_INLINE static constexpr std::false_type match(const Reader&)
219  {
220  return {};
221  }
222 };
223 template <typename H, typename... T>
224 struct _node_char_class_impl<0, true, H, T...>
225 {
226  template <typename Reader>
227  LEXY_FORCE_INLINE static constexpr bool match(Reader reader)
228  {
229  return lexy::token_parser_for<H, Reader>(reader).try_parse(reader);
230  }
231 };
232 template <std::size_t Idx, typename H, typename... T>
233 struct _node_char_class_impl<Idx, true, H, T...> : _node_char_class_impl<Idx - 1, true, T...>
234 {};
235 template <std::size_t CharClassIdx, typename... CharClasses>
236 using _node_char_class
237  = _node_char_class_impl<CharClassIdx, (CharClassIdx < sizeof...(CharClasses)), CharClasses...>;
238 
239 template <const auto& Trie, std::size_t CurNode>
241 template <typename Encoding, template <typename> typename CaseFolding, std::size_t N,
242  typename... CharClasses, const lit_trie<Encoding, CaseFolding, N, CharClasses...>& Trie,
243  std::size_t CurNode>
244 struct lit_trie_matcher<Trie, CurNode>
245 {
246  template <std::size_t TransIdx, typename Reader, typename IntT>
247  LEXY_FORCE_INLINE static constexpr bool _try_transition(std::size_t& result, Reader& reader,
248  IntT cur)
249  {
250  static_assert(Trie.transition_from[TransIdx] == CurNode);
251 
252  using encoding = typename Reader::encoding;
253  constexpr auto trans_char = Trie.transition_char[TransIdx];
254  if (cur != encoding::to_int_type(trans_char))
255  return false;
256 
257  reader.bump();
259  return true;
260  }
261 
262  static constexpr auto transitions = Trie.node_transitions(CurNode);
263 
264  template <typename Indices = make_index_sequence<transitions.length>>
265  struct _impl;
266  template <std::size_t... Idx>
267  struct _impl<index_sequence<Idx...>>
268  {
269  template <typename Reader>
270  LEXY_FORCE_INLINE static constexpr std::size_t try_match(Reader& reader)
271  {
272  constexpr auto cur_value = Trie.node_value[CurNode];
273 
274  if constexpr (sizeof...(Idx) > 0)
275  {
276  auto cur = reader.current();
277  auto cur_char = reader.peek();
278 
279  auto next_value = Trie.node_no_match;
280  (void)(_try_transition<transitions.index[Idx]>(next_value, reader, cur_char)
281  || ...);
282  if (next_value != Trie.node_no_match)
283  // We prefer a longer match.
284  return next_value;
285 
286  // We haven't found a longer match, return our match.
287  reader.reset(cur);
288  }
289 
290  // But first, we might need to check that we don't match that nodes char class.
291  constexpr auto char_class = Trie.node_char_class[CurNode];
292  if constexpr (cur_value == Trie.node_no_match || char_class >= sizeof...(CharClasses))
293  {
294  return cur_value;
295  }
296  else
297  {
299  return Trie.node_no_match;
300  else
301  return cur_value;
302  }
303  }
304  };
305 
306  template <typename Reader>
307  LEXY_FORCE_INLINE static constexpr std::size_t try_match(Reader& _reader)
308  {
309  static_assert(lexy::is_char_encoding<typename Reader::encoding>);
310  if constexpr (std::is_same_v<CaseFolding<Reader>, Reader>)
311  {
312  return _impl<>::try_match(_reader);
313  }
314  else
315  {
316  CaseFolding<Reader> reader{_reader};
317  auto result = _impl<>::try_match(reader);
318  _reader.reset(reader.current());
319  return result;
320  }
321  }
322 };
323 } // namespace lexy::_detail
324 
325 //=== lit ===//
326 namespace lexyd
327 {
328 template <typename CharT, CharT... C>
329 struct _lit
330 : token_base<_lit<CharT, C...>,
331  std::conditional_t<sizeof...(C) == 0, unconditional_branch_base, branch_base>>,
332  _lit_base
333 {
334  static constexpr auto lit_max_char_count = sizeof...(C);
337 
338  template <typename Encoding>
339  static constexpr auto lit_first_char() -> typename Encoding::char_type
340  {
341  typename Encoding::char_type result = 0;
342  (void)((result = lexy::_detail::transcode_char<decltype(result)>(C), true) || ...);
343  return result;
344  }
345 
346  template <typename Trie>
347  static LEXY_CONSTEVAL std::size_t lit_insert(Trie& trie, std::size_t pos, std::size_t)
348  {
349  return ((pos = trie.insert(pos, C)), ...);
350  }
351 
352  template <typename Reader>
353  struct tp
354  {
355  typename Reader::marker end;
356 
357  constexpr explicit tp(const Reader& reader) : end(reader.current()) {}
358 
359  constexpr auto try_parse(Reader reader)
360  {
361  auto result = lexy::_detail::match_literal<0, CharT, C...>(reader);
362  end = reader.current();
363  return result;
364  }
365 
366  template <typename Context>
367  constexpr void report_error(Context& context, const Reader& reader)
368  {
369  using char_type = typename Reader::encoding::char_type;
370  constexpr auto str = lexy::_detail::type_string<CharT, C...>::template c_str<char_type>;
371 
372  auto begin = reader.position();
373  auto index = lexy::_detail::range_size(begin, end.position());
374  auto err = lexy::error<Reader, lexy::expected_literal>(begin, str, index, sizeof...(C));
375  context.on(_ev::error{}, err);
376  }
377  };
378 };
379 
380 template <auto C>
381 constexpr auto lit_c = _lit<LEXY_DECAY_DECLTYPE(C), C>{};
382 
383 template <unsigned char... C>
384 constexpr auto lit_b = _lit<unsigned char, C...>{};
385 
386 #if LEXY_HAS_NTTP
387 template <lexy::_detail::string_literal Str>
389 constexpr auto lit = lexy::_detail::to_type_string<_lit, Str>{};
390 #endif
391 
392 #define LEXY_LIT(Str) \
393  LEXY_NTTP_STRING(::lexyd::_lit, Str) {}
394 } // namespace lexyd
395 
396 namespace lexy
397 {
398 template <typename CharT, CharT... C>
399 inline constexpr auto token_kind_of<lexy::dsl::_lit<CharT, C...>> = lexy::literal_token_kind;
400 } // namespace lexy
401 
402 //=== lit_cp ===//
403 namespace lexyd
404 {
405 template <char32_t... Cp>
406 struct _lcp : token_base<_lcp<Cp...>>, _lit_base
407 {
408  template <typename Encoding>
409  struct _string_t
410  {
411  typename Encoding::char_type data[4 * sizeof...(Cp)];
412  std::size_t length = 0;
413 
414  constexpr _string_t() : data{}
415  {
416  ((length += lexy::_detail::encode_code_point<Encoding>(Cp, data + length, 4)), ...);
417  }
418  };
419  template <typename Encoding>
421 
422  static constexpr auto lit_max_char_count = 4 * sizeof...(Cp);
425 
426  template <typename Encoding>
427  static constexpr auto lit_first_char() -> typename Encoding::char_type
428  {
429  return _string<Encoding>.data[0];
430  }
431 
432  template <typename Trie>
433  static LEXY_CONSTEVAL std::size_t lit_insert(Trie& trie, std::size_t pos, std::size_t)
434  {
435  using encoding = typename Trie::encoding;
436 
437  for (auto i = 0u; i != _string<encoding>.length; ++i)
438  pos = trie.insert(pos, _string<encoding>.data[i]);
439 
440  return pos;
441  }
442 
443  template <typename Reader,
444  typename Indices
446  struct tp;
447  template <typename Reader, std::size_t... Idx>
448  struct tp<Reader, lexy::_detail::index_sequence<Idx...>>
449  {
450  typename Reader::marker end;
451 
452  constexpr explicit tp(const Reader& reader) : end(reader.current()) {}
453 
454  constexpr bool try_parse(Reader reader)
455  {
456  using encoding = typename Reader::encoding;
457 
458  auto result = lexy::_detail::match_literal<0, typename encoding::char_type,
459  _string<encoding>.data[Idx]...>(reader);
460  end = reader.current();
461  return result;
462  }
463 
464  template <typename Context>
465  constexpr void report_error(Context& context, const Reader& reader)
466  {
467  using encoding = typename Reader::encoding;
468 
469  auto begin = reader.position();
470  auto index = lexy::_detail::range_size(begin, end.position());
471  auto err = lexy::error<Reader, lexy::expected_literal>(begin, _string<encoding>.data,
472  index, _string<encoding>.length);
473  context.on(_ev::error{}, err);
474  }
475  };
476 };
477 
478 template <char32_t... CodePoint>
479 constexpr auto lit_cp = _lcp<CodePoint...>{};
480 } // namespace lexyd
481 
482 namespace lexy
483 {
484 template <char32_t... Cp>
485 constexpr auto token_kind_of<lexy::dsl::_lcp<Cp...>> = lexy::literal_token_kind;
486 } // namespace lexy
487 
488 //=== lit_set ===//
489 namespace lexy
490 {
491 template <typename T, template <typename> typename CaseFolding, typename... Strings>
493 
495 {
496  static LEXY_CONSTEVAL auto name()
497  {
498  return "expected literal set";
499  }
500 };
501 } // namespace lexy
502 
503 namespace lexyd
504 {
505 template <typename Literal, template <typename> typename CaseFolding>
506 struct _cfl;
507 
508 template <template <typename> typename CaseFolding, typename CharT, CharT... C>
510 {
511  if constexpr (std::is_same_v<CaseFolding<lexy::_pr8>, lexy::_pr8>)
512  return _lit<CharT, C...>{};
513  else
514  return _cfl<_lit<CharT, C...>, CaseFolding>{};
515 }
516 
517 template <typename... Literals>
518 struct _lset : token_base<_lset<Literals...>>, _lset_base
519 {
520  using as_lset = _lset;
521 
522  template <typename Encoding>
524  {
525  auto result = lexy::_detail::make_empty_trie<Encoding, Literals...>();
526 
527  [[maybe_unused]] auto char_class = std::size_t(0);
528  ((result.node_value[Literals::lit_insert(result, 0, char_class)] = 0,
529  // Keep the index correct.
530  char_class += Literals::lit_char_classes.size),
531  ...);
532 
533  return result;
534  }
535  template <typename Encoding>
536  static constexpr lexy::_detail::lit_trie_for<Encoding, Literals...> _t
537  = _build_trie<Encoding>();
538 
539  template <typename Reader>
540  struct tp
541  {
542  typename Reader::marker end;
543 
544  constexpr explicit tp(const Reader& reader) : end(reader.current()) {}
545 
546  constexpr bool try_parse(Reader reader)
547  {
548  using encoding = typename Reader::encoding;
550 
551  auto result = matcher::try_match(reader);
552  end = reader.current();
553  return result != _t<encoding>.node_no_match;
554  }
555 
556  template <typename Context>
557  constexpr void report_error(Context& context, const Reader& reader)
558  {
559  auto err = lexy::error<Reader, lexy::expected_literal_set>(reader.position());
560  context.on(_ev::error{}, err);
561  }
562  };
563 
564  //=== dsl ===//
565  template <typename Lit>
566  constexpr auto operator/(Lit) const
567  {
568  if constexpr (lexy::is_literal_rule<Lit>)
569  {
570  return _lset<Literals..., Lit>{};
571  }
572  else if constexpr (sizeof...(Literals) == 0)
573  {
574  // We're empty, so do nothing and keep it type-erased.
575  static_assert(lexy::is_literal_set_rule<Lit>);
576  return Lit{};
577  }
578  else
579  {
580  // We're non empty, undo type erasure to append.
581  static_assert(lexy::is_literal_set_rule<Lit>);
582  return *this / typename Lit::as_lset{};
583  }
584  }
585  template <typename... Lit>
586  constexpr auto operator/(_lset<Lit...>) const
587  {
588  return _lset<Literals..., Lit...>{};
589  }
590 };
591 
593 template <typename... Literals>
594 constexpr auto literal_set(Literals...)
595 {
596  static_assert((lexy::is_literal_rule<Literals> && ...));
597  return _lset<Literals...>{};
598 }
599 
601 template <typename T, template <typename> typename CaseFolding, typename... Strings>
603 {
604  return _lset<decltype(_make_lit_rule<CaseFolding>(Strings{}))...>{};
605 }
606 } // namespace lexyd
607 
608 #define LEXY_LITERAL_SET(...) \
609  [] { \
610  using impl = decltype(::lexyd::literal_set(__VA_ARGS__)); \
611  struct s : impl \
612  { \
613  using impl::operator/; \
614  }; \
615  return s{}; \
616  }()
617 
618 namespace lexy
619 {
620 template <typename... Literals>
621 constexpr auto token_kind_of<lexy::dsl::_lset<Literals...>> = lexy::literal_token_kind;
622 } // namespace lexy
623 
624 #endif // LEXY_DSL_LITERAL_HPP_INCLUDED
625 
lexy::_detail::lit_trie< Encoding, CaseFolding, _max_char_count >::char_type
typename Encoding::char_type char_type
Definition: literal.hpp:71
lexy::_detail::lit_trie::node_char_class
std::size_t node_char_class[max_node_count]
Definition: literal.hpp:85
lexy::_detail::lit_trie_matcher< Trie, CurNode >::_impl< index_sequence< Idx... > >::try_match
static constexpr LEXY_FORCE_INLINE std::size_t try_match(Reader &reader)
Definition: literal.hpp:270
code_point.hpp
LEXY_CONSTEVAL
#define LEXY_CONSTEVAL
Definition: config.hpp:98
lexy::_detail::index_sequence
integer_sequence< std::size_t, Indices... > index_sequence
Definition: integer_sequence.hpp:17
lexy::_detail::lit_trie::lit_trie
LEXY_CONSTEVAL lit_trie()
Definition: literal.hpp:91
lexyd::_lset::operator/
constexpr auto operator/(Lit) const
Definition: literal.hpp:566
lexy::_detail::transcode_char
LEXY_CONSTEVAL TargetCharT transcode_char(CharT c)
Definition: encoding.hpp:300
token.hpp
lexy::_symbol_table
Definition: literal.hpp:492
lexyd::_lcp::tp
Definition: literal.hpp:446
magic_enum::char_type
string_view::value_type char_type
Definition: magic_enum.hpp:145
iterator.hpp
lexy::_detail::lit_trie::transition_char
char_type transition_char[max_transition_count]
Definition: literal.hpp:87
lexyd::_lcp::_string_t
Definition: literal.hpp:409
lexy::_detail::char_class_list
Definition: literal.hpp:154
lexyd::_lcp::tp< Reader, lexy::_detail::index_sequence< Idx... > >::tp
constexpr tp(const Reader &reader)
Definition: literal.hpp:452
lexyd::_lset::_t
static constexpr lexy::_detail::lit_trie_for< Encoding, Literals... > _t
Definition: literal.hpp:537
lexy::_detail::_merge_case_folding< CurrentCaseFolding >::case_folding
typename CurrentCaseFolding::template reader< Reader > case_folding
Definition: literal.hpp:180
lexy::_detail::lit_trie_for
decltype(make_empty_trie< Encoding, Literals... >()) lit_trie_for
Definition: literal.hpp:212
lexyd::_lcp::lit_max_char_count
static constexpr auto lit_max_char_count
Definition: literal.hpp:422
lexy::_detail::_merge_case_folding
Definition: literal.hpp:169
lexyd::_lcp::_string_t::length
std::size_t length
Definition: literal.hpp:412
lexyd::_lset::operator/
constexpr auto operator/(_lset< Lit... >) const
Definition: literal.hpp:586
lexy::_detail::lit_trie::node_transitions
LEXY_CONSTEVAL auto node_transitions(std::size_t node) const
Definition: literal.hpp:133
lexyd::_lset::tp::report_error
constexpr void report_error(Context &context, const Reader &reader)
Definition: literal.hpp:557
lexy::_detail::lit_trie::insert
LEXY_CONSTEVAL std::size_t insert(std::size_t from, CharT _c)
Definition: literal.hpp:100
lexy::_detail::type_string
Definition: nttp_string.hpp:15
lexy::expected_literal_set::name
static LEXY_CONSTEVAL auto name()
Definition: literal.hpp:496
lexy::_detail::_merge_case_folding< void >::case_folding
Reader case_folding
Definition: literal.hpp:174
lexyd::_lcp::tp< Reader, lexy::_detail::index_sequence< Idx... > >::report_error
constexpr void report_error(Context &context, const Reader &reader)
Definition: literal.hpp:465
lexy::_detail::integer_sequence
Definition: integer_sequence.hpp:12
lexy
Definition: any_ref.hpp:12
lexyd::_cfl
Definition: case_folding.hpp:23
lexy::literal_token_kind
@ literal_token_kind
Definition: grammar.hpp:90
lexy::_detail::make_index_sequence
typename _make_index_sequence< Size >::type make_index_sequence
Definition: integer_sequence.hpp:55
cx::end
constexpr auto end(const C &c) -> decltype(c.end())
Definition: wildcards.hpp:686
lexyd::_lset::tp::end
Reader::marker end
Definition: literal.hpp:542
detail::void
j template void())
Definition: json.hpp:4893
lexyd::_lit::tp::tp
constexpr tp(const Reader &reader)
Definition: literal.hpp:357
lexy::_detail::lit_trie_matcher< Trie, CurNode >::_try_transition
static constexpr LEXY_FORCE_INLINE bool _try_transition(std::size_t &result, Reader &reader, IntT cur)
Definition: literal.hpp:247
lexy::error
Generic failure.
Definition: error.hpp:14
lexyd::_lcp::lit_case_folding
void lit_case_folding
Definition: literal.hpp:424
lexyd::_lcp::_string_t::data
Encoding::char_type data[4 *sizeof...(Cp)]
Definition: literal.hpp:411
lexyd::_lcp::tp< Reader, lexy::_detail::index_sequence< Idx... > >::end
Reader::marker end
Definition: literal.hpp:450
lexy::_detail::lit_trie::insert
LEXY_CONSTEVAL std::size_t insert(std::size_t pos, type_string< CharT, C... >)
Definition: literal.hpp:128
swar.hpp
lexy::_detail::char_class_list::size
static constexpr auto size
Definition: literal.hpp:159
lexy::_detail::lit_trie::max_node_count
static constexpr auto max_node_count
Definition: literal.hpp:76
lexy::_detail::lit_trie< Encoding, CaseFolding, _max_char_count >::encoding
Encoding encoding
Definition: literal.hpp:70
lexy::parse_events::error
Definition: dsl/base.hpp:68
lexyd::token_base
Definition: dsl/token.hpp:42
lexy::_detail::lit_no_case_fold
Reader lit_no_case_fold
Definition: literal.hpp:196
lexyd::_lset_base
Definition: grammar.hpp:30
lexy::_detail::lit_trie::node_value
std::size_t node_value[max_node_count]
Definition: literal.hpp:82
lexy::_detail::lit_trie
Definition: literal.hpp:68
LEXY_DECAY_DECLTYPE
#define LEXY_DECAY_DECLTYPE(...)
Definition: config.hpp:34
lexyd::_lset::_build_trie
static LEXY_CONSTEVAL auto _build_trie()
Definition: literal.hpp:523
lexyd::_lit::lit_insert
static LEXY_CONSTEVAL std::size_t lit_insert(Trie &trie, std::size_t pos, std::size_t)
Definition: literal.hpp:347
lexy::_detail::range_size
constexpr std::size_t range_size(Iterator begin, Sentinel end)
Definition: iterator.hpp:22
lexyd::_lset::tp::tp
constexpr tp(const Reader &reader)
Definition: literal.hpp:544
lexyd::_make_lit_rule
constexpr auto _make_lit_rule(lexy::_detail::type_string< CharT, C... >)
Definition: literal.hpp:509
lexyd::_lit::tp::end
Reader::marker end
Definition: literal.hpp:355
integer_sequence.hpp
cx::begin
constexpr auto begin(const C &c) -> decltype(c.begin())
Definition: wildcards.hpp:661
lexy::_detail::_node_char_class_impl
Definition: literal.hpp:215
lexyd::_lit::tp::report_error
constexpr void report_error(Context &context, const Reader &reader)
Definition: literal.hpp:367
base.hpp
lexyd::_lit::lit_max_char_count
static constexpr auto lit_max_char_count
Definition: literal.hpp:334
lexy::_detail
Definition: any_ref.hpp:12
lexy::_detail::match_literal
constexpr auto match_literal(Reader &reader)
Definition: literal.hpp:19
lexyd::_lcp::_string_t::_string_t
constexpr _string_t()
Definition: literal.hpp:414
lexy::_detail::_node_char_class_impl::match
static constexpr LEXY_FORCE_INLINE std::false_type match(const Reader &)
Definition: literal.hpp:218
lexyd::_lit
Definition: char_class.hpp:300
nttp_string.hpp
LEXY_FORCE_INLINE
#define LEXY_FORCE_INLINE
Definition: config.hpp:171
lexyd::ascii::case_folding
constexpr auto case_folding
Matches Literal with case insensitive ASCII characters.
Definition: case_folding.hpp:139
lexyd::lit_c
constexpr auto lit_c
Definition: literal.hpp:381
lexyd::_lit::tp
Definition: literal.hpp:353
lexy::_detail::lit_trie::node_no_match
static constexpr auto node_no_match
Definition: literal.hpp:79
lexyd::_lit::lit_char_classes
static constexpr auto lit_char_classes
Definition: literal.hpp:335
lexy::_detail::lit_trie_matcher
Definition: literal.hpp:240
lexy::_detail::lit_trie::transition_from
std::size_t transition_from[max_transition_count]
Definition: literal.hpp:88
lexyd::_lset::tp
Definition: literal.hpp:540
lexyd::_lcp::lit_first_char
static constexpr auto lit_first_char() -> typename Encoding::char_type
Definition: literal.hpp:427
lexyd::_lcp::tp< Reader, lexy::_detail::index_sequence< Idx... > >::try_parse
constexpr bool try_parse(Reader reader)
Definition: literal.hpp:454
lexyd::literal_set
constexpr auto literal_set(Literals...)
Matches one of the specified literals.
Definition: literal.hpp:594
lexyd::_lcp
Definition: char_class.hpp:302
lexy::_detail::lit_trie::transition_to
std::size_t transition_to[max_transition_count]
Definition: literal.hpp:89
lexyd::lit_cp
constexpr auto lit_cp
Definition: literal.hpp:479
lexy::_detail::lit_trie::max_transition_count
static constexpr auto max_transition_count
Definition: literal.hpp:78
lexyd::_lcp::lit_char_classes
static constexpr auto lit_char_classes
Definition: literal.hpp:423
lexyd::_lcp::_string
static constexpr _string_t< Encoding > _string
Definition: literal.hpp:420
lexy::_detail::_node_char_class_impl< 0, true, H, T... >::match
static constexpr LEXY_FORCE_INLINE bool match(Reader reader)
Definition: literal.hpp:227
lexyd::_lcp::lit_insert
static LEXY_CONSTEVAL std::size_t lit_insert(Trie &trie, std::size_t pos, std::size_t)
Definition: literal.hpp:433
lexy::_detail::make_empty_trie
LEXY_CONSTEVAL auto make_empty_trie()
Definition: literal.hpp:199
lexyd::_lset::tp::try_parse
constexpr bool try_parse(Reader reader)
Definition: literal.hpp:546
lexy::token_parser_for
typename TokenRule::template tp< Reader > token_parser_for
Definition: dsl/base.hpp:242
lexyd::_lit< unsigned char >::lit_case_folding
void lit_case_folding
Definition: literal.hpp:336
lexyd
Definition: trace.hpp:22
lexy::_detail::char_class_list::operator+
constexpr auto operator+(char_class_list< T... >) const
Definition: literal.hpp:162
lexyd::_lit::lit_first_char
static constexpr auto lit_first_char() -> typename Encoding::char_type
Definition: literal.hpp:339
lexyd::_lset
Definition: literal.hpp:518
lexy::expected_literal_set
Definition: literal.hpp:494
lexyd::lit_b
constexpr auto lit_b
Definition: literal.hpp:384
lexyd::_lit::tp::try_parse
constexpr auto try_parse(Reader reader)
Definition: literal.hpp:359
lexy::_detail::lit_trie::node_count
std::size_t node_count
Definition: literal.hpp:81
lexy::_detail::lit_trie< Encoding, CaseFolding, _max_char_count >::reader
CaseFolding< Reader > reader
Definition: literal.hpp:74
lexy::_detail::lit_trie_matcher< Trie, CurNode >::try_match
static constexpr LEXY_FORCE_INLINE std::size_t try_match(Reader &_reader)
Definition: literal.hpp:307
lexy::token_kind_of
constexpr auto token_kind_of
Specialize to define the token kind of a rule.
Definition: grammar.hpp:137


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Dec 13 2024 03:19:17