Header lexy/input/lexeme_input.hpp

Input lexy::lexeme_input

namespace lexy
  template <input auto ParentInput>
  class lexeme_input
      using lexeme-type = lexeme_for<ParentInput>;

      using encoding  = typename lexeme-type::encoding;
      using char_type = typename lexeme-type::char_type;
      using iterator  = typename lexeme-type::iterator;

      //=== constructor ===//
      explicit lexeme_input(const ParentInput& input, lexeme-type lexeme);

      explicit lexeme_input(const ParentInput& input, iterator begin, iterator end);

      //=== access ===//
      const ParentInput& parent_input() const;
      lexeme-type lexeme() const;

      //=== input ===//
      reader auto reader() const& noexcept;

The class lexy::lexeme_input uses a lexy::lexeme  as the input.

A lexeme is a subset of an existing input, the parent input, which must be provided as well. If the parent input is a view-like input (e.g. lexy::string_input  or lexy::range_input , it stores a copy. Otherwise, if the parent input owns the input (e.g. lexy::buffer ), it stores a pointer to the parent input.

If an error is generated on a lexeme input, lexy::error_context  will return the parent input. That way, any calls to lexy::get_input_location  will result in the correct line/column information for the entire input, and don’t start at the partial input.

Use lexy::lexeme_input if the input is parsed in multiple passes.

See also