MCPcopy Create free account
hub / github.com/boostorg/parser / symbol_parser

Class symbol_parser

include/boost/parser/parser.hpp:5276–5458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5274
5275 template<typename T>
5276 struct symbol_parser
5277 {
5278 symbol_parser() : copied_from_(nullptr) {}
5279 explicit symbol_parser(std::string_view diagnostic_text) :
5280 copied_from_(nullptr), diagnostic_text_(diagnostic_text)
5281 {}
5282 symbol_parser(symbol_parser const & other) :
5283 initial_elements_(other.initial_elements_),
5284 copied_from_(other.copied_from_ ? other.copied_from_ : &other),
5285 diagnostic_text_(other.diagnostic_text_)
5286 {}
5287 symbol_parser(symbol_parser && other) :
5288 initial_elements_(std::move(other.initial_elements_)),
5289 copied_from_(other.copied_from_),
5290 diagnostic_text_(other.diagnostic_text_)
5291 {}
5292
5293 /** Inserts an entry consisting of a UTF-8 string `str` to match, and
5294 an associated attribute `x`, to `*this`. The entry is added for
5295 use in all subsequent top-level parses. Subsequent lookups during
5296 the current top-level parse will not necessarily match `str`. */
5297 template<typename Context>
5298 void insert_for_next_parse(
5299 Context const & context, std::string_view str, T x)
5300 {
5301 auto & pending_ops =
5302 detail::get_pending_symtab_ops(context, ref());
5303 pending_ops.push_back(detail::symbol_table_operation<T>{
5304 std::string(str),
5305 std::move(x),
5306 detail::symbol_table_op::insert});
5307 }
5308
5309 /** Erases the entry whose UTF-8 match string is `str`, from `*this`.
5310 The entry will no longer be available for use in all subsequent
5311 top-level parses. `str` will not be removed from the symbols
5312 matched in the current top-level parse. */
5313 template<typename Context>
5314 void erase_for_next_parse(Context const & context, std::string_view str)
5315 {
5316 auto & pending_ops =
5317 detail::get_pending_symtab_ops(context, ref());
5318 pending_ops.push_back(detail::symbol_table_operation<T>{
5319 std::string(str),
5320 std::nullopt,
5321 detail::symbol_table_op::erase});
5322 }
5323
5324 /** Erases all the entries from the copy of the symbol table inside
5325 the parse context `context`. */
5326 template<typename Context>
5327 void clear_for_next_parse(Context const & context)
5328 {
5329 auto & pending_ops =
5330 detail::get_pending_symtab_ops(context, ref());
5331 pending_ops.push_back(detail::symbol_table_operation<T>{
5332 {}, std::nullopt, detail::symbol_table_op::clear});
5333 }

Callers 1

operator()Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected