symbol.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_SYMBOL_HPP_INCLUDED
5 #define LEXY_DSL_SYMBOL_HPP_INCLUDED
6 
7 #include <lexy/dsl/base.hpp>
8 #include <lexy/dsl/capture.hpp>
9 #include <lexy/dsl/literal.hpp>
10 #include <lexy/error.hpp>
11 #include <lexy/lexeme.hpp>
12 
13 namespace lexy
14 {
15 #define LEXY_SYMBOL(Str) LEXY_NTTP_STRING(::lexy::_detail::type_string, Str)
16 
17 template <typename T, template <typename> typename CaseFolding, typename... Strings>
18 class _symbol_table
19 {
20  static auto _char_type()
21  {
22  if constexpr (sizeof...(Strings) == 0)
23  return;
24  else
25  return std::common_type_t<typename Strings::char_type...>{};
26  }
27 
28 public:
29  using char_type = decltype(_char_type());
31  using mapped_type = T;
32 
33  struct value_type
34  {
35  const char_type* symbol;
37  };
38 
39  //=== modifiers ===//
41 
42  template <typename CaseFoldingDSL>
43  LEXY_CONSTEVAL auto case_folding(CaseFoldingDSL) const
44  {
45  return _symbol_table<T, CaseFoldingDSL::template case_folding,
46  Strings...>(_detail::make_index_sequence<size()>{}, *this);
47  }
48 
49  template <typename SymbolString, typename... Args>
50  LEXY_CONSTEVAL auto map(Args&&... args) const
51  {
52  using next_table = _symbol_table<T, CaseFolding, Strings..., SymbolString>;
53  if constexpr (empty())
54  return next_table(_detail::make_index_sequence<0>{}, nullptr, LEXY_FWD(args)...);
55  else
56  return next_table(_detail::make_index_sequence<size()>{}, _data, LEXY_FWD(args)...);
57  }
58 
59 #if LEXY_HAS_NTTP
60  template <_detail::string_literal SymbolString, typename... Args>
61  LEXY_CONSTEVAL auto map(Args&&... args) const
62  {
63  return map<_detail::to_type_string<_detail::type_string, SymbolString>>(LEXY_FWD(args)...);
64  }
65 #else
66 # if (defined(__clang__) && __clang_major__ <= 7) \
67  || (defined(__clang__) && defined(__apple_build_version__) && __clang_major__ <= 10)
68  template <char C, typename... Args> // Sorry, compiler bug.
69 # else
70  template <auto C, typename... Args>
71 # endif
72  LEXY_CONSTEVAL auto map(Args&&... args) const
73  {
74  return map<_detail::type_string<LEXY_DECAY_DECLTYPE(C), C>>(LEXY_FWD(args)...);
75  }
76 #endif
77 
78  template <typename CharT, CharT... C, typename... Args>
79  LEXY_CONSTEVAL auto map(lexyd::_lit<CharT, C...>, Args&&... args) const
80  {
81  return map<_detail::type_string<CharT, C...>>(LEXY_FWD(args)...);
82  }
83 
84  //=== access ===//
85  static constexpr bool empty() noexcept
86  {
87  return size() == 0;
88  }
89 
90  static constexpr std::size_t size() noexcept
91  {
92  return sizeof...(Strings);
93  }
94 
95  class iterator
96  : public lexy::_detail::bidirectional_iterator_base<iterator, value_type, value_type, void>
97  {
98  public:
99  constexpr iterator() noexcept : _table(nullptr), _idx(0) {}
100 
101  constexpr value_type deref() const noexcept
102  {
103  if constexpr (empty())
104  {
105  LEXY_PRECONDITION(false);
106  return value_type{"", LEXY_DECLVAL(T)};
107  }
108  else
109  {
111  constexpr const char_type* strings[] = {Strings::template c_str<char_type>...};
112  return value_type{strings[_idx], _table->_data[_idx]};
113  }
114  }
115 
116  constexpr void increment() noexcept
117  {
118  LEXY_PRECONDITION(_idx != sizeof...(Strings));
119  ++_idx;
120  }
121  constexpr void decrement() noexcept
122  {
123  LEXY_PRECONDITION(_idx != 0);
124  --_idx;
125  }
126 
127  constexpr bool equal(iterator rhs) const noexcept
128  {
129  LEXY_PRECONDITION(_table == rhs._table);
130  return _idx == rhs._idx;
131  }
132 
133  private:
134  constexpr iterator(const _symbol_table* table, std::size_t idx) noexcept
135  : _table(table), _idx(idx)
136  {}
137 
139  std::size_t _idx;
140 
142  };
143 
144  constexpr iterator begin() const noexcept
145  {
146  return iterator(this, 0);
147  }
148  constexpr iterator end() const noexcept
149  {
150  return iterator(this, size());
151  }
152 
153  struct key_index
154  {
155  std::size_t _value;
156 
157  constexpr key_index() noexcept : _value(std::size_t(-1)) {}
158  constexpr explicit key_index(std::size_t idx) noexcept : _value(idx)
159  {
161  }
162 
163  constexpr explicit operator bool() const noexcept
164  {
165  return _value < size();
166  }
167 
168  friend constexpr bool operator==(key_index lhs, key_index rhs) noexcept
169  {
170  return lhs._value == rhs._value;
171  }
172  friend constexpr bool operator!=(key_index lhs, key_index rhs) noexcept
173  {
174  return lhs._value != rhs._value;
175  }
176  };
177 
178  template <typename Reader>
179  constexpr key_index try_parse(Reader& reader) const
180  {
181  static_assert(!empty(), "symbol table must not be empty");
182  using encoding = typename Reader::encoding;
183 
184  auto result = _detail::lit_trie_matcher<_trie<encoding>, 0>::try_match(reader);
185  if (result == _trie<encoding>.node_no_match)
186  return key_index();
187  else
188  return key_index(result);
189  }
190 
191  template <typename Input>
192  constexpr key_index parse(const Input& input) const
193  {
194  auto reader = input.reader();
195  auto result = try_parse(reader);
196  if (reader.peek() == decltype(reader)::encoding::eof())
197  return result;
198  else
199  return key_index();
200  }
201 
202  constexpr const T& operator[](key_index idx) const noexcept
203  {
204  LEXY_PRECONDITION(idx);
205  return _data[idx._value];
206  }
207 
208 private:
209  static constexpr auto _max_char_count = (0 + ... + Strings::size);
210 
211  template <typename Encoding>
213  {
215 
216  auto idx = 0u;
217  ((result.node_value[result.insert(0, Strings{})] = idx++), ...);
218 
219  return result;
220  }
221  template <typename Encoding>
223  = _build_trie<Encoding>();
224 
225  template <std::size_t... Idx, typename... Args>
226  constexpr explicit _symbol_table(lexy::_detail::index_sequence<Idx...>, const T* data,
227  Args&&... args)
228  // New data is appended at the end.
229  : _data{data[Idx]..., T(LEXY_FWD(args)...)}
230  {}
231  template <std::size_t... Idx, template <typename> typename OtherCaseFolding>
234  : _data{table._data[Idx]...}
235  {}
236 
237  std::conditional_t<empty(), char, T> _data[empty() ? 1 : size()];
238 
239  template <typename, template <typename> typename, typename...>
240  friend class _symbol_table;
241 };
242 
243 template <typename T>
245 } // namespace lexy
246 
247 namespace lexy
248 {
250 {
251  static LEXY_CONSTEVAL auto name()
252  {
253  return "unknown symbol";
254  }
255 };
256 } // namespace lexy
257 
258 namespace lexyd
259 {
260 template <typename Leading, typename Trailing>
261 struct _idp;
262 template <typename Leading, typename Trailing, typename... Reserved>
263 struct _id;
264 
265 template <const auto& Table, typename Token, typename Tag>
266 struct _sym : branch_base
267 {
268  template <typename Reader>
269  struct bp
270  {
271  static_assert(lexy::is_char_encoding<typename Reader::encoding>);
272  typename Reader::marker end;
273  typename LEXY_DECAY_DECLTYPE(Table)::key_index symbol;
274 
275  constexpr auto value() const
276  {
277  return Table[symbol];
278  }
279 
280  template <typename ControlBlock>
281  constexpr bool try_parse(ControlBlock&, const Reader& reader)
282  {
283  // Try and parse the token.
285  if (!parser.try_parse(reader))
286  return false;
287  end = parser.end;
288 
289  // Check whether this is a symbol.
290  auto content = lexy::partial_input(reader, end.position());
291  symbol = Table.parse(content);
292 
293  // Only succeed if it is a symbol.
294  return static_cast<bool>(symbol);
295  }
296 
297  template <typename Context>
298  constexpr void cancel(Context&)
299  {}
300 
301  template <typename NextParser, typename Context, typename... Args>
302  LEXY_PARSER_FUNC bool finish(Context& context, Reader& reader, Args&&... args)
303  {
304  // We need to consume and report the token.
305  context.on(_ev::token{}, Token{}, reader.position(), end.position());
306  reader.reset(end);
307 
308  // And continue parsing with the symbol value after whitespace skipping.
310  return continuation::parse(context, reader, LEXY_FWD(args)..., Table[symbol]);
311  }
312  };
313 
314  template <typename NextParser>
315  struct p
316  {
317  template <typename... PrevArgs>
318  struct _cont
319  {
320  template <typename Context, typename Reader>
321  LEXY_PARSER_FUNC static bool parse(Context& context, Reader& reader, PrevArgs&&... args,
323  {
324  // Check whether the captured lexeme is a symbol.
325  auto content = lexy::partial_input(reader, lexeme.begin(), lexeme.end());
326  auto symbol = Table.parse(content);
327  if (!symbol)
328  {
329  // Unknown symbol.
331  auto err = lexy::error<Reader, tag>(lexeme.begin(), lexeme.end());
332  context.on(_ev::error{}, err);
333  return false;
334  }
335 
336  // Continue parsing with the symbol value.
337  return NextParser::parse(context, reader, LEXY_FWD(args)..., Table[symbol]);
338  }
339  };
340 
341  template <typename Context, typename Reader, typename... Args>
342  LEXY_PARSER_FUNC static bool parse(Context& context, Reader& reader, Args&&... args)
343  {
344  static_assert(lexy::is_char_encoding<typename Reader::encoding>);
345  // Capture the token and continue with special continuation.
346  return lexy::parser_for<_cap<Token>, _cont<Args...>>::parse(context, reader,
347  LEXY_FWD(args)...);
348  }
349  };
350 
351  //=== dsl ===//
352  template <typename ErrorTag>
353  static constexpr _sym<Table, Token, ErrorTag> error = {};
354 };
355 
356 // Optimization for identifiers: instead of parsing an entire identifier (which requires checking
357 // every character against the char class), parse a symbol and check whether the next character
358 // would continue the identifier. This is the same optimization that is done for keywords.
359 template <const auto& Table, typename L, typename T, typename Tag>
360 struct _sym<Table, _idp<L, T>, Tag> : branch_base
361 {
362  template <typename Reader>
363  struct bp
364  {
365  static_assert(lexy::is_char_encoding<typename Reader::encoding>);
366  typename LEXY_DECAY_DECLTYPE(Table)::key_index symbol;
367  typename Reader::marker end;
368 
369  constexpr auto value() const
370  {
371  return Table[symbol];
372  }
373 
374  constexpr bool try_parse(const void*, Reader reader)
375  {
376  // Try to parse a symbol.
377  symbol = Table.try_parse(reader);
378  if (!symbol)
379  return false;
380  end = reader.current();
381 
382  // We had a symbol, but it must not be the prefix of a valid identifier.
383  return !lexy::try_match_token(T{}, reader);
384  }
385 
386  template <typename Context>
387  constexpr void cancel(Context&)
388  {}
389 
390  template <typename NextParser, typename Context, typename... Args>
391  LEXY_PARSER_FUNC bool finish(Context& context, Reader& reader, Args&&... args)
392  {
393  // We need to consume and report the identifier pattern.
394  context.on(_ev::token{}, _idp<L, T>{}, reader.position(), end.position());
395  reader.reset(end);
396 
397  // And continue parsing with the symbol value after whitespace skipping.
399  return continuation::parse(context, reader, LEXY_FWD(args)..., Table[symbol]);
400  }
401  };
402 
403  template <typename NextParser>
404  struct p
405  {
406  template <typename Context, typename Reader, typename... Args>
407  LEXY_PARSER_FUNC static bool parse(Context& context, Reader& reader, Args&&... args)
408  {
409  static_assert(lexy::is_char_encoding<typename Reader::encoding>);
410  auto begin = reader.position();
411 
412  // Try to parse a symbol that is not the prefix of an identifier.
413  auto symbol_reader = reader;
414  auto symbol = Table.try_parse(symbol_reader);
415  if (!symbol || lexy::try_match_token(T{}, symbol_reader))
416  {
417  // Unknown symbol or not an identifier.
418  // Parse the identifier pattern normally, and see if that fails.
420  if (!id_parser::parse(context, reader))
421  // It did fail, so it reported an error and we're done here.
422  return false;
423 
424  // We're having a valid identifier but unknown symbol.
426  auto err = lexy::error<Reader, tag>(begin, reader.position());
427  context.on(_ev::error{}, err);
428 
429  return false;
430  }
431  else
432  {
433  // We need to consume and report the identifier pattern.
434  auto end = symbol_reader.current();
435  context.on(_ev::token{}, _idp<L, T>{}, begin, end.position());
436  reader.reset(end);
437 
438  // And continue parsing with the symbol value after whitespace skipping.
440  return continuation::parse(context, reader, LEXY_FWD(args)..., Table[symbol]);
441  }
442  }
443  };
444 
445  //=== dsl ===//
446  template <typename ErrorTag>
447  static constexpr _sym<Table, _idp<L, T>, ErrorTag> error = {};
448 };
449 
450 template <const auto& Table, typename Tag>
451 struct _sym<Table, void, Tag> : branch_base
452 {
453  template <typename Reader>
454  struct bp
455  {
456  static_assert(lexy::is_char_encoding<typename Reader::encoding>);
457  typename LEXY_DECAY_DECLTYPE(Table)::key_index symbol;
458  typename Reader::marker end;
459 
460  constexpr auto value() const
461  {
462  return Table[symbol];
463  }
464 
465  constexpr bool try_parse(const void*, Reader reader)
466  {
467  // Try to parse a symbol.
468  symbol = Table.try_parse(reader);
469  end = reader.current();
470 
471  // Only succeed if it is a symbol.
472  return static_cast<bool>(symbol);
473  }
474 
475  template <typename Context>
476  constexpr void cancel(Context&)
477  {}
478 
479  template <typename NextParser, typename Context, typename... Args>
480  LEXY_PARSER_FUNC bool finish(Context& context, Reader& reader, Args&&... args)
481  {
482  // We need to consume and report the token.
483  context.on(_ev::token{}, lexy::identifier_token_kind, reader.position(),
484  end.position());
485  reader.reset(end);
486 
487  // And continue parsing with the symbol value after whitespace skipping.
489  return continuation::parse(context, reader, LEXY_FWD(args)..., Table[symbol]);
490  }
491  };
492 
493  template <typename NextParser>
494  struct p
495  {
496  template <typename Context, typename Reader, typename... Args>
497  LEXY_PARSER_FUNC static bool parse(Context& context, Reader& reader, Args&&... args)
498  {
499  static_assert(lexy::is_char_encoding<typename Reader::encoding>);
500  bp<Reader> impl{};
501  if (impl.try_parse(context.control_block, reader))
502  return impl.template finish<NextParser>(context, reader, LEXY_FWD(args)...);
503  impl.cancel(context);
504 
505  // Unknown symbol.
507  auto err = lexy::error<Reader, tag>(reader.position());
508  context.on(_ev::error{}, err);
509 
510  return false;
511  }
512  };
513 
514  //=== dsl ===//
515  template <typename ErrorTag>
516  static constexpr _sym<Table, void, ErrorTag> error = {};
517 };
518 
519 template <const auto& Table>
520 struct _sym_dsl : _sym<Table, void, void>
521 {
522  template <typename Token>
523  constexpr auto operator()(Token) const
524  {
525  static_assert(lexy::is_token_rule<Token>);
526  return _sym<Table, Token, void>{};
527  }
528  template <typename L, typename T, typename... R>
529  constexpr auto operator()(_id<L, T, R...> id) const
530  {
531  static_assert(sizeof...(R) == 0,
532  "symbol() must not be used in the presence of reserved identifiers");
533  return _sym<Table, decltype(id.pattern()), void>{};
534  }
535 };
536 
538 template <const auto& Table>
539 constexpr auto symbol = _sym_dsl<Table>{};
540 } // namespace lexyd
541 
542 #endif // LEXY_DSL_SYMBOL_HPP_INCLUDED
543 
cx::size
constexpr auto size(const C &c) -> decltype(c.size())
Definition: wildcards.hpp:636
lexyd::_sym< Table, void, Tag >::bp::cancel
constexpr void cancel(Context &)
Definition: symbol.hpp:476
LEXY_CONSTEVAL
#define LEXY_CONSTEVAL
Definition: config.hpp:98
lexyd::branch_base
Definition: grammar.hpp:20
lexy::_symbol_table::_build_trie
static LEXY_CONSTEVAL auto _build_trie()
Definition: symbol.hpp:212
lexyd::_sym
Definition: flags.hpp:24
lexyd::_sym< Table, void, Tag >::bp::try_parse
constexpr bool try_parse(const void *, Reader reader)
Definition: symbol.hpp:465
lexy::_symbol_table::_trie
static constexpr lexy::_detail::lit_trie< Encoding, CaseFolding, _max_char_count > _trie
Definition: symbol.hpp:223
lexyd::_sym< Table, _idp< L, T >, Tag >::bp::finish
LEXY_PARSER_FUNC bool finish(Context &context, Reader &reader, Args &&... args)
Definition: symbol.hpp:391
lexy::_symbol_table::key_index::operator==
constexpr friend bool operator==(key_index lhs, key_index rhs) noexcept
Definition: symbol.hpp:168
lexy::_symbol_table::_symbol_table
constexpr _symbol_table(lexy::_detail::index_sequence< Idx... >, const _symbol_table< T, OtherCaseFolding, Strings... > &table)
Definition: symbol.hpp:232
lexyd::_sym::p::_cont
Definition: symbol.hpp:318
literal.hpp
lexy::_symbol_table
Definition: literal.hpp:492
lexy::_symbol_table::iterator::iterator
constexpr iterator(const _symbol_table *table, std::size_t idx) noexcept
Definition: symbol.hpp:134
lexy::_symbol_table::empty
static constexpr bool empty() noexcept
Definition: symbol.hpp:85
magic_enum::char_type
string_view::value_type char_type
Definition: magic_enum.hpp:145
lexy::_detail::forward_iterator_base< iterator, value_type, value_type, void >::value_type
std::remove_cv_t< value_type > value_type
Definition: iterator.hpp:159
lexy::_symbol_table::iterator::deref
constexpr value_type deref() const noexcept
Definition: symbol.hpp:101
lexyd::_sym_dsl::operator()
constexpr auto operator()(_id< L, T, R... > id) const
Definition: symbol.hpp:529
lexyd::_sym< Table, void, Tag >::bp::finish
LEXY_PARSER_FUNC bool finish(Context &context, Reader &reader, Args &&... args)
Definition: symbol.hpp:480
lexyd::_sym_dsl::operator()
constexpr auto operator()(Token) const
Definition: symbol.hpp:523
lexy::_symbol_table::_symbol_table
friend class _symbol_table
Definition: symbol.hpp:240
lexy::_symbol_table::key_index::key_index
constexpr key_index(std::size_t idx) noexcept
Definition: symbol.hpp:158
lexy::_symbol_table::_symbol_table
LEXY_CONSTEVAL _symbol_table()
Definition: symbol.hpp:40
lexyd::_idp
Definition: identifier.hpp:34
lexy::symbol_table
constexpr auto symbol_table
Definition: symbol.hpp:244
lexyd::_id
Definition: identifier.hpp:142
LEXY_FWD
#define LEXY_FWD(...)
Definition: config.hpp:30
lexy::_symbol_table::end
constexpr iterator end() const noexcept
Definition: symbol.hpp:148
lexy::_detail::type_or
std::conditional_t< std::is_void_v< T >, Fallback, T > type_or
Definition: config.hpp:64
lexy::_detail::lit_trie::insert
LEXY_CONSTEVAL std::size_t insert(std::size_t from, CharT _c)
Definition: literal.hpp:100
lexyd::_sym< Table, _idp< L, T >, Tag >::bp::end
LEXY_DECAY_DECLTYPE(Table) Reader::marker end
Definition: symbol.hpp:366
lexy::_detail::type_string
Definition: nttp_string.hpp:15
lexy::_symbol_table::iterator::_symbol_table
friend _symbol_table
Definition: symbol.hpp:141
lexy::_symbol_table::size
static constexpr std::size_t size() noexcept
Definition: symbol.hpp:90
lexyd::_sym< Table, void, Tag >::bp::end
LEXY_DECAY_DECLTYPE(Table) Reader::marker end
Definition: symbol.hpp:457
lexy::_detail::integer_sequence
Definition: integer_sequence.hpp:12
lexy
Definition: any_ref.hpp:12
lexyd::_sym< Table, void, Tag >::bp::value
constexpr auto value() const
Definition: symbol.hpp:460
LEXY_PRECONDITION
#define LEXY_PRECONDITION(Expr)
Definition: assert.hpp:36
lexy::_symbol_table::_data
std::conditional_t< empty(), char, T > _data[empty() ? 1 :size()]
Definition: symbol.hpp:237
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
lexy::_symbol_table::value_type::symbol
const char_type * symbol
Definition: symbol.hpp:35
lexy::_symbol_table::key_index::operator!=
constexpr friend bool operator!=(key_index lhs, key_index rhs) noexcept
Definition: symbol.hpp:172
lexyd::_sym::p::parse
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, Args &&... args)
Definition: symbol.hpp:342
lexyd::_sym< Table, _idp< L, T >, Tag >::bp::try_parse
constexpr bool try_parse(const void *, Reader reader)
Definition: symbol.hpp:374
lexy::error
Generic failure.
Definition: error.hpp:14
lexy::unknown_symbol
Definition: symbol.hpp:249
lexy::_symbol_table::iterator::equal
constexpr bool equal(iterator rhs) const noexcept
Definition: symbol.hpp:127
lexy::_symbol_table::iterator::iterator
constexpr iterator() noexcept
Definition: symbol.hpp:99
lexy::_symbol_table::key_index
Definition: symbol.hpp:153
lexy::_symbol_table::key_index::_value
std::size_t _value
Definition: symbol.hpp:155
lexy::parse
constexpr auto parse(const Input &input, const ErrorCallback &callback)
Parses the production into a value, invoking the callback on error.
Definition: parse.hpp:171
lexyd::symbol
constexpr auto symbol
Parses optional rule, then matches the resulting lexeme against the symbol table.
Definition: symbol.hpp:539
lexyd::_sym::bp::end
Reader::marker end
Definition: symbol.hpp:271
lexy::_symbol_table::value_type::value
const mapped_type & value
Definition: symbol.hpp:36
lexy::_symbol_table::map
LEXY_CONSTEVAL auto map(lexyd::_lit< CharT, C... >, Args &&... args) const
Definition: symbol.hpp:79
capture.hpp
lexy::parse_events::error
Definition: dsl/base.hpp:68
lexy::_symbol_table::iterator::decrement
constexpr void decrement() noexcept
Definition: symbol.hpp:121
lexy::try_match_token
constexpr LEXY_FORCE_INLINE auto try_match_token(TokenRule, Reader &reader)
Definition: dsl/base.hpp:245
lexeme.hpp
lexy::_symbol_table::_max_char_count
static constexpr auto _max_char_count
Definition: symbol.hpp:209
lexy::_detail::lit_trie::node_value
std::size_t node_value[max_node_count]
Definition: literal.hpp:82
lexy::_detail::lit_trie< Encoding, CaseFolding, _max_char_count >
LEXY_DECAY_DECLTYPE
#define LEXY_DECAY_DECLTYPE(...)
Definition: config.hpp:34
lexy::partial_input
constexpr auto partial_input(const Reader &, typename Reader::iterator begin, typename Reader::iterator end)
Definition: input/base.hpp:133
lexy::_symbol_table::char_type
decltype(_char_type()) char_type
Definition: symbol.hpp:29
LEXY_PARSER_FUNC
#define LEXY_PARSER_FUNC
Definition: dsl/base.hpp:108
lexyd::_sym_dsl
Definition: symbol.hpp:520
cx::begin
constexpr auto begin(const C &c) -> decltype(c.begin())
Definition: wildcards.hpp:661
lexy::_symbol_table::key_index::key_index
constexpr key_index() noexcept
Definition: symbol.hpp:157
lexy::whitespace_parser
Definition: dsl/base.hpp:229
lexy::_symbol_table::begin
constexpr iterator begin() const noexcept
Definition: symbol.hpp:144
lexy::_symbol_table::try_parse
constexpr key_index try_parse(Reader &reader) const
Definition: symbol.hpp:179
lexyd::_sym::p
Definition: symbol.hpp:315
base.hpp
lexy::pattern_parser
A parser that does not support any arguments.
Definition: dsl/base.hpp:172
lexyd::_lit
Definition: char_class.hpp:300
lexyd::_sym::bp::finish
LEXY_PARSER_FUNC bool finish(Context &context, Reader &reader, Args &&... args)
Definition: symbol.hpp:302
lexy::parse_events::token
Definition: dsl/base.hpp:57
std
Definition: std.hpp:31
lexy::_symbol_table::iterator::_table
const _symbol_table * _table
Definition: symbol.hpp:138
lexyd::_sym::bp::cancel
constexpr void cancel(Context &)
Definition: symbol.hpp:298
lexy::lexeme
Definition: lexeme.hpp:16
lexy::_symbol_table::value_type
Definition: symbol.hpp:33
lexy::identifier_token_kind
@ identifier_token_kind
Definition: grammar.hpp:94
lexy::_symbol_table::iterator
Definition: symbol.hpp:95
lexy::_detail::bidirectional_iterator_base
Definition: iterator.hpp:202
lexyd::_sym::bp
Definition: symbol.hpp:269
lexyd::_sym::bp::try_parse
constexpr bool try_parse(ControlBlock &, const Reader &reader)
Definition: symbol.hpp:281
lexy::_detail::lit_trie_matcher
Definition: literal.hpp:240
lexy::lexeme
lexeme(const Reader &, typename Reader::iterator) -> lexeme< typename Reader::canonical_reader >
lexyd::_sym< Table, void, Tag >::p::parse
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, Args &&... args)
Definition: symbol.hpp:497
lexy::parser_for
typename Rule::template p< NextParser > parser_for
Definition: dsl/base.hpp:113
lexy::_detail::error
constexpr bool error
Definition: config.hpp:47
lexyd::_sym< Table, _idp< L, T >, Tag >::p::parse
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, Args &&... args)
Definition: symbol.hpp:407
lexyd::_sym< Table, _idp< L, T >, Tag >::bp::value
constexpr auto value() const
Definition: symbol.hpp:369
lexyd::_sym::bp::value
constexpr LEXY_DECAY_DECLTYPE(Table) auto value() const
Definition: symbol.hpp:275
lexy::_symbol_table::iterator::increment
constexpr void increment() noexcept
Definition: symbol.hpp:116
lexyd::_sym::p::_cont::parse
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, PrevArgs &&... args, lexy::lexeme< Reader > lexeme)
Definition: symbol.hpp:321
lexy::_symbol_table::case_folding
LEXY_CONSTEVAL auto case_folding(CaseFoldingDSL) const
Definition: symbol.hpp:43
lexyd::_sym< Table, _idp< L, T >, Tag >::bp::cancel
constexpr void cancel(Context &)
Definition: symbol.hpp:387
lexy::_symbol_table::parse
constexpr key_index parse(const Input &input) const
Definition: symbol.hpp:192
LEXY_DECLVAL
#define LEXY_DECLVAL(...)
Definition: config.hpp:32
lexy::_symbol_table::_symbol_table
constexpr _symbol_table(lexy::_detail::index_sequence< Idx... >, const T *data, Args &&... args)
Definition: symbol.hpp:226
lexy::_symbol_table::map
LEXY_CONSTEVAL auto map(Args &&... args) const
Definition: symbol.hpp:50
lexy::_symbol_table::_char_type
static auto _char_type()
Definition: symbol.hpp:20
lexy::token_parser_for
typename TokenRule::template tp< Reader > token_parser_for
Definition: dsl/base.hpp:242
lexy::_symbol_table::operator[]
constexpr const T & operator[](key_index idx) const noexcept
Definition: symbol.hpp:202
lexy::_symbol_table::key_type
char_type key_type
Definition: symbol.hpp:30
lexyd
Definition: trace.hpp:22
lexy::_symbol_table::iterator::_idx
std::size_t _idx
Definition: symbol.hpp:139
lexyd::eof
constexpr auto eof
Matches EOF.
Definition: eof.hpp:72
lexy::_symbol_table::mapped_type
T mapped_type
Definition: symbol.hpp:31
lexyd::p
constexpr auto p
Parses the production.
Definition: production.hpp:127
lexy::unknown_symbol::name
static LEXY_CONSTEVAL auto name()
Definition: symbol.hpp:251
error.hpp


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