| Home | Libraries | People | FAQ | More

## Struct template symbols

boost::parser::symbols

## Synopsis

    // In header: <boost/parser/parser.hpp>

    template<typename T>
    struct symbols : public boost::parser::parser_interface< symbol_parser< T > > {

      // public member functions
      symbols();
      symbols(char const *);
      symbols(std::initializer_list< std::pair< std::string_view, T > >);
      symbols(char const *,
              std::initializer_list< std::pair< std::string_view, T > >);
      void insert_for_next_parse(std::string_view, T);
      void erase_for_next_parse(std::string_view);
      void clear_for_next_parse();
      template<typename Context>
        void insert_for_next_parse(Context const &, std::string_view, T);
      template<typename Context>
        void erase_for_next_parse(Context const &, std::string_view);
      template<typename Context> void clear_for_next_parse(Context const &);
      template<typename Context>
        unspecified find(Context const &, std::string_view) const;
      template<typename Context>
        void insert(Context const &, std::string_view, T) const;
      template<typename Context>
        void erase(Context const &, std::string_view) const;
      template<typename Context> void clear(Context const &) const;
    };

## Description

A `symbols<T>` represents the initial state of a symbol table parser that produces attributes of type `T`. The entries in the symbol table can be changed during parsing, but those mutations do not affect the `symbols<T>` object itself; all mutations happen to a copy of the symbol table in the parse context. For table entries that should be used during every parse, add entries via `add()` or `operator()`. For mid-parse mutations, use `insert()` and `erase()`.

### `symbols` public member functions

1.     symbols();

2.     symbols(char const * diagnostic_text);

3.     symbols(std::initializer_list< std::pair< std::string_view, T > > il);

4.     symbols(char const * diagnostic_text,
               std::initializer_list< std::pair< std::string_view, T > > il);

5.     void insert_for_next_parse(std::string_view str, T x);

   Inserts an entry consisting of a UTF-8 string `str` to match, and an associated attribute `x`, to `*this`. The entry is added for use in all subsequent top-level parses. Subsequent lookups during the current top-level parse will not necessarily match `str`.

6.     void erase_for_next_parse(std::string_view str);

   Erases the entry whose UTF-8 match string is `str`, from `*this`. The entry will no longer be available for use in all subsequent top-level parses. `str` will not be removed from the symbols matched in the current top-level parse.

7.     void clear_for_next_parse();

   Erases all the entries from the copy of the symbol table inside the parse context `context`.

8.     template<typename Context>
         void insert_for_next_parse(Context const & context, std::string_view str,
                                    T x);

   Inserts an entry consisting of a UTF-8 string `str` to match, and an associated attribute `x`, to `*this`. The entry is added for use in all subsequent top-level parses. Subsequent lookups during the current top-level parse will not necessarily match `str`.

9.     template<typename Context>
         void erase_for_next_parse(Context const & context, std::string_view str);

   Erases the entry whose UTF-8 match string is `str`, from `*this`. The entry will no longer be available for use in all subsequent top-level parses. `str` will not be removed from the symbols matched in the current top-level parse.

10.     template<typename Context> void clear_for_next_parse(Context const & context);

    Erases all the entries from the copy of the symbol table inside the parse context `context`.

11.     template<typename Context>
          unspecified find(Context const & context, std::string_view str) const;

    Uses UTF-8 string `str` to look up an attribute in the table during parsing, returning it as an optional reference. The lookup is done on the copy of the symbol table inside the parse context `context`, not `*this`.

12.     template<typename Context>
          void insert(Context const & context, std::string_view str, T x) const;

    Inserts an entry consisting of a UTF-8 string to match `str`, and an associated attribute `x`, to the copy of the symbol table inside the parse context `context`.

13.     template<typename Context>
          void erase(Context const & context, std::string_view str) const;

    Erases the entry whose UTF-8 match string is `str` from the copy of the symbol table inside the parse context `context`.

14.     template<typename Context> void clear(Context const & context) const;

    Erases all the entries from the copy of the symbol table inside the parse context `context`.