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


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Tue Jun 25 2024 02:20:36