symbol.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_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  typename Reader::iterator end;
272  typename LEXY_DECAY_DECLTYPE(Table)::key_index symbol;
273 
274  constexpr auto value() const
275  {
276  return Table[symbol];
277  }
278 
279  template <typename ControlBlock>
280  constexpr bool try_parse(ControlBlock&, const Reader& reader)
281  {
282  // Try and parse the token.
284  if (!parser.try_parse(reader))
285  return false;
286  end = parser.end;
287 
288  // Check whether this is a symbol.
289  auto content = lexy::partial_input(reader, end);
290  symbol = Table.parse(content);
291 
292  // Only succeed if it is a symbol.
293  return static_cast<bool>(symbol);
294  }
295 
296  template <typename Context>
297  constexpr void cancel(Context&)
298  {}
299 
300  template <typename NextParser, typename Context, typename... Args>
301  LEXY_PARSER_FUNC bool finish(Context& context, Reader& reader, Args&&... args)
302  {
303  // We need to consume and report the token.
304  context.on(_ev::token{}, Token{}, reader.position(), end);
305  reader.set_position(end);
306 
307  // And continue parsing with the symbol value after whitespace skipping.
309  return continuation::parse(context, reader, LEXY_FWD(args)..., Table[symbol]);
310  }
311  };
312 
313  template <typename NextParser>
314  struct p
315  {
316  template <typename... PrevArgs>
317  struct _cont
318  {
319  template <typename Context, typename Reader>
320  LEXY_PARSER_FUNC static bool parse(Context& context, Reader& reader, PrevArgs&&... args,
322  {
323  // Check whether the captured lexeme is a symbol.
324  auto content = lexy::partial_input(reader, lexeme.begin(), lexeme.end());
325  auto symbol = Table.parse(content);
326  if (!symbol)
327  {
328  // Unknown symbol.
330  auto err = lexy::error<Reader, tag>(lexeme.begin(), lexeme.end());
331  context.on(_ev::error{}, err);
332  return false;
333  }
334 
335  // Continue parsing with the symbol value.
336  return NextParser::parse(context, reader, LEXY_FWD(args)..., Table[symbol]);
337  }
338  };
339 
340  template <typename Context, typename Reader, typename... Args>
341  LEXY_PARSER_FUNC static bool parse(Context& context, Reader& reader, Args&&... args)
342  {
343  // Capture the token and continue with special continuation.
344  return lexy::parser_for<_cap<Token>, _cont<Args...>>::parse(context, reader,
345  LEXY_FWD(args)...);
346  }
347  };
348 
349  //=== dsl ===//
350  template <typename ErrorTag>
351  static constexpr _sym<Table, Token, ErrorTag> error = {};
352 };
353 
354 // Optimization for identifiers: instead of parsing an entire identifier (which requires checking
355 // every character against the char class), parse a symbol and check whether the next character
356 // would continue the identifier. This is the same optimization that is done for keywords.
357 template <const auto& Table, typename L, typename T, typename Tag>
358 struct _sym<Table, _idp<L, T>, Tag> : branch_base
359 {
360  template <typename Reader>
361  struct bp
362  {
363  typename LEXY_DECAY_DECLTYPE(Table)::key_index symbol;
364  typename Reader::iterator end;
365 
366  constexpr auto value() const
367  {
368  return Table[symbol];
369  }
370 
371  constexpr bool try_parse(const void*, Reader reader)
372  {
373  // Try to parse a symbol.
374  symbol = Table.try_parse(reader);
375  if (!symbol)
376  return false;
377  end = reader.position();
378 
379  // We had a symbol, but it must not be the prefix of a valid identifier.
380  return !lexy::try_match_token(T{}, reader);
381  }
382 
383  template <typename Context>
384  constexpr void cancel(Context&)
385  {}
386 
387  template <typename NextParser, typename Context, typename... Args>
388  LEXY_PARSER_FUNC bool finish(Context& context, Reader& reader, Args&&... args)
389  {
390  // We need to consume and report the identifier pattern.
391  context.on(_ev::token{}, _idp<L, T>{}, reader.position(), end);
392  reader.set_position(end);
393 
394  // And continue parsing with the symbol value after whitespace skipping.
396  return continuation::parse(context, reader, LEXY_FWD(args)..., Table[symbol]);
397  }
398  };
399 
400  template <typename NextParser>
401  struct p
402  {
403  template <typename Context, typename Reader, typename... Args>
404  LEXY_PARSER_FUNC static bool parse(Context& context, Reader& reader, Args&&... args)
405  {
406  auto begin = reader.position();
407 
408  // Try to parse a symbol that is not the prefix of an identifier.
409  auto symbol_reader = reader;
410  auto symbol = Table.try_parse(symbol_reader);
411  if (!symbol || lexy::try_match_token(T{}, symbol_reader))
412  {
413  // Unknown symbol or not an identifier.
414  // Parse the identifier pattern normally, and see if that fails.
416  if (!id_parser::parse(context, reader))
417  // It did fail, so it reported an error and we're done here.
418  return false;
419 
420  // We're having a valid identifier but unknown symbol.
422  auto err = lexy::error<Reader, tag>(begin, reader.position());
423  context.on(_ev::error{}, err);
424 
425  return false;
426  }
427  else
428  {
429  // We need to consume and report the identifier pattern.
430  auto end = symbol_reader.position();
431  context.on(_ev::token{}, _idp<L, T>{}, begin, end);
432  reader.set_position(end);
433 
434  // And continue parsing with the symbol value after whitespace skipping.
436  return continuation::parse(context, reader, LEXY_FWD(args)..., Table[symbol]);
437  }
438  }
439  };
440 
441  //=== dsl ===//
442  template <typename ErrorTag>
443  static constexpr _sym<Table, _idp<L, T>, ErrorTag> error = {};
444 };
445 
446 template <const auto& Table, typename Tag>
447 struct _sym<Table, void, Tag> : branch_base
448 {
449  template <typename Reader>
450  struct bp
451  {
452  typename LEXY_DECAY_DECLTYPE(Table)::key_index symbol;
453  typename Reader::iterator end;
454 
455  constexpr auto value() const
456  {
457  return Table[symbol];
458  }
459 
460  constexpr bool try_parse(const void*, Reader reader)
461  {
462  // Try to parse a symbol.
463  symbol = Table.try_parse(reader);
464  end = reader.position();
465 
466  // Only succeed if it is a symbol.
467  return static_cast<bool>(symbol);
468  }
469 
470  template <typename Context>
471  constexpr void cancel(Context&)
472  {}
473 
474  template <typename NextParser, typename Context, typename... Args>
475  LEXY_PARSER_FUNC bool finish(Context& context, Reader& reader, Args&&... args)
476  {
477  // We need to consume and report the token.
478  context.on(_ev::token{}, lexy::identifier_token_kind, reader.position(), end);
479  reader.set_position(end);
480 
481  // And continue parsing with the symbol value after whitespace skipping.
483  return continuation::parse(context, reader, LEXY_FWD(args)..., Table[symbol]);
484  }
485  };
486 
487  template <typename NextParser>
488  struct p
489  {
490  template <typename Context, typename Reader, typename... Args>
491  LEXY_PARSER_FUNC static bool parse(Context& context, Reader& reader, Args&&... args)
492  {
493  bp<Reader> impl{};
494  if (impl.try_parse(context.control_block, reader))
495  return impl.template finish<NextParser>(context, reader, LEXY_FWD(args)...);
496  impl.cancel(context);
497 
498  // Unknown symbol.
500  auto err = lexy::error<Reader, tag>(reader.position());
501  context.on(_ev::error{}, err);
502 
503  return false;
504  }
505  };
506 
507  //=== dsl ===//
508  template <typename ErrorTag>
509  static constexpr _sym<Table, void, ErrorTag> error = {};
510 };
511 
512 template <const auto& Table>
513 struct _sym_dsl : _sym<Table, void, void>
514 {
515  template <typename Token>
516  constexpr auto operator()(Token) const
517  {
518  static_assert(lexy::is_token_rule<Token>);
519  return _sym<Table, Token, void>{};
520  }
521  template <typename L, typename T, typename... R>
522  constexpr auto operator()(_id<L, T, R...> id) const
523  {
524  static_assert(sizeof...(R) == 0,
525  "symbol() must not be used in the presence of reserved identifiers");
526  return _sym<Table, decltype(id.pattern()), void>{};
527  }
528 };
529 
531 template <const auto& Table>
532 constexpr auto symbol = _sym_dsl<Table>{};
533 } // namespace lexyd
534 
535 #endif // LEXY_DSL_SYMBOL_HPP_INCLUDED
536 
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:471
LEXY_CONSTEVAL
#define LEXY_CONSTEVAL
Definition: config.hpp:90
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:460
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:388
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:317
literal.hpp
lexy::_symbol_table
Definition: literal.hpp:490
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:522
lexyd::_sym< Table, void, Tag >::bp::finish
LEXY_PARSER_FUNC bool finish(Context &context, Reader &reader, Args &&... args)
Definition: symbol.hpp:475
lexyd::_sym_dsl::operator()
constexpr auto operator()(Token) const
Definition: symbol.hpp:516
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:140
LEXY_FWD
#define LEXY_FWD(...)
Definition: config.hpp:22
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:56
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::_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
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:455
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
lexyd::_sym::bp::end
Reader::iterator end
Definition: symbol.hpp:271
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:341
lexyd::_sym< Table, _idp< L, T >, Tag >::bp::try_parse
constexpr bool try_parse(const void *, Reader reader)
Definition: symbol.hpp:371
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:532
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:55
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:232
lexeme.hpp
lexy::_symbol_table::_max_char_count
static constexpr auto _max_char_count
Definition: symbol.hpp:209
lexyd::_sym< Table, void, Tag >::bp::end
LEXY_DECAY_DECLTYPE(Table) Reader::iterator end
Definition: symbol.hpp:452
lexy::_detail::lit_trie::node_value
std::size_t node_value[max_node_count]
Definition: literal.hpp:81
lexy::_detail::lit_trie< Encoding, CaseFolding, _max_char_count >
LEXY_DECAY_DECLTYPE
#define LEXY_DECAY_DECLTYPE(...)
Definition: config.hpp:26
lexy::partial_input
constexpr auto partial_input(const Reader &, typename Reader::iterator begin, typename Reader::iterator end)
Definition: input/base.hpp:119
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:95
lexyd::_sym_dsl
Definition: symbol.hpp:513
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:216
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:314
base.hpp
lexy::pattern_parser
A parser that does not support any arguments.
Definition: dsl/base.hpp:159
lexyd::_lit
Definition: char_class.hpp:299
lexyd::_sym::bp::finish
LEXY_PARSER_FUNC bool finish(Context &context, Reader &reader, Args &&... args)
Definition: symbol.hpp:301
lexy::parse_events::token
Definition: dsl/base.hpp:44
std
Definition: std.hpp:30
lexy::_symbol_table::iterator::_table
const _symbol_table * _table
Definition: symbol.hpp:138
lexyd::_sym::bp::cancel
constexpr void cancel(Context &)
Definition: symbol.hpp:297
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:85
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:280
lexy::_detail::lit_trie_matcher
Definition: literal.hpp:239
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:491
lexyd::_sym< Table, _idp< L, T >, Tag >::bp::end
LEXY_DECAY_DECLTYPE(Table) Reader::iterator end
Definition: symbol.hpp:363
lexy::parser_for
typename Rule::template p< NextParser > parser_for
Definition: dsl/base.hpp:100
lexy::_detail::error
constexpr bool error
Definition: config.hpp:39
lexyd::_sym< Table, _idp< L, T >, Tag >::p::parse
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, Args &&... args)
Definition: symbol.hpp:404
lexyd::_sym< Table, _idp< L, T >, Tag >::bp::value
constexpr auto value() const
Definition: symbol.hpp:366
lexyd::_sym::bp::value
constexpr LEXY_DECAY_DECLTYPE(Table) auto value() const
Definition: symbol.hpp:274
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:320
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:384
lexy::_symbol_table::parse
constexpr key_index parse(const Input &input) const
Definition: symbol.hpp:192
LEXY_DECLVAL
#define LEXY_DECLVAL(...)
Definition: config.hpp:24
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:229
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 Jun 28 2024 02:20:08