...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::parser::parser_interface
// In header: <boost/parser/parser.hpp> template<typename Parser, typename GlobalState, typename ErrorHandler> struct parser_interface { // types typedef Parser parser_type; typedef GlobalState global_state_type; typedef ErrorHandler error_handler_type; typedef int parser_interface_derivation_tag; // public member functions parser_interface(); parser_interface(parser_type); parser_interface(parser_type, global_state_type, error_handler_type); constexpr auto operator!() const noexcept; constexpr auto operator&() const noexcept; constexpr auto operator*() const noexcept; constexpr auto operator+() const noexcept; constexpr auto operator-() const noexcept; template<typename ParserType2> constexpr auto operator>>(parser_interface< ParserType2 >) const noexcept; constexpr auto operator>>(char) const noexcept; constexpr auto operator>>(char32_t) const noexcept; template<parsable_range_like R> constexpr auto operator>>(R &&) const noexcept; template<typename ParserType2> constexpr auto operator>(parser_interface< ParserType2 >) const noexcept; constexpr auto operator>(char) const noexcept; constexpr auto operator>(char32_t) const noexcept; template<parsable_range_like R> constexpr auto operator>(R &&) const noexcept; template<typename ParserType2> constexpr auto operator|(parser_interface< ParserType2 >) const noexcept; template<typename ParserType2> constexpr auto operator||(parser_interface< ParserType2 >) const noexcept; constexpr auto operator|(char) const noexcept; constexpr auto operator|(char32_t) const noexcept; template<parsable_range_like R> constexpr auto operator|(R &&) const noexcept; template<typename ParserType2> constexpr auto operator-(parser_interface< ParserType2 >) const noexcept; constexpr auto operator-(char) const noexcept; constexpr auto operator-(char32_t) const noexcept; template<parsable_range_like R> constexpr auto operator-(R &&) const noexcept; template<typename ParserType2> constexpr auto operator%(parser_interface< ParserType2 >) const noexcept; constexpr auto operator%(char) const noexcept; constexpr auto operator%(char32_t) const noexcept; template<parsable_range_like R> constexpr auto operator%(R &&) const noexcept; template<typename Action> constexpr auto operator[](Action) const; template<typename Arg, typename... Args> constexpr auto operator()(Arg &&, Args &&...) const noexcept; };
A wrapper for parsers that provides the operations that must be supported by all parsers (e.g. operator>>()
). GlobalState
is an optional state object that can be accessed within semantic actions via a call to _globals()
. This global state object is ignored for all but the topmost parser; the topmost global state object is available in the semantic actions of all nested parsers. ErrorHandler
is the type of the error handler to be used on parse failure. This handler is ignored on all but the topmost parser; the topmost parser's error handler is used for all errors encountered during parsing.
parser_interface
public member functionsparser_interface();
parser_interface(parser_type p);
parser_interface(parser_type p, global_state_type gs, error_handler_type eh);
constexpr auto operator!() const noexcept;
Returns a parser_interface
containing a parser equivalent to an expect_parser
containing parser_
, with FailOnMatch == true
.
constexpr auto operator&() const noexcept;
Returns a parser_interface
containing a parser equivalent to an expect_parser
containing parser_
, with FailOnMatch == false
.
constexpr auto operator*() const noexcept;
Returns a parser_interface
containing a parser equivalent to a zero_plus_parser
containing parser_
.
constexpr auto operator+() const noexcept;
Returns a parser_interface
containing a parser equivalent to a one_plus_parser
containing parser_
.
constexpr auto operator-() const noexcept;
Returns a parser_interface
containing a parser equivalent to a opt_parser
containing parser_
.
template<typename ParserType2> constexpr auto operator>>(parser_interface< ParserType2 > rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to a seq_parser
containing parser_
followed by rhs.parser_
.
constexpr auto operator>>(char rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to a seq_parser
containing parser_
followed by lit(rhs)
.
constexpr auto operator>>(char32_t rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to a seq_parser
containing parser_
followed by lit(rhs)
.
template<parsable_range_like R> constexpr auto operator>>(R && r) const noexcept;
Returns a parser_interface
containing a parser equivalent to a seq_parser
containing parser_
followed by lit(rhs)
.
template<typename ParserType2> constexpr auto operator>(parser_interface< ParserType2 > rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to a seq_parser
containing parser_
followed by rhs.parser_
. No back-tracking is allowed after parser_
succeeds; if rhs.parser_
fails after parser_
succeeds, the top-level parse fails.
constexpr auto operator>(char rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to a seq_parser
containing parser_
followed by lit(rhs)
. No back-tracking is allowed after parser_
succeeds; if lit(rhs)
fails after parser_
succeeds, the top-level parse fails.
constexpr auto operator>(char32_t rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to a seq_parser
containing parser_
followed by lit(rhs)
. No back-tracking is allowed after parser_
succeeds; if lit(rhs)
fails after parser_
succeeds, the top-level parse fails.
template<parsable_range_like R> constexpr auto operator>(R && r) const noexcept;
Returns a parser_interface
containing a parser equivalent to a seq_parser
containing parser_
followed by lit(rhs)
. No back-tracking is allowed after parser_
succeeds; if lit(rhs)
fails after parser_
succeeds, the top-level parse fails.
template<typename ParserType2> constexpr auto operator|(parser_interface< ParserType2 > rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to an or_parser
containing parser_
followed by rhs.parser_
.
template<typename ParserType2> constexpr auto operator||(parser_interface< ParserType2 > rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to a perm_parser
containing parser_
followed by rhs.parser_
. It is an error to use eps
(conditional or not) with this operator.
constexpr auto operator|(char rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to an or_parser
containing parser_
followed by lit(rhs)
.
constexpr auto operator|(char32_t rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to an or_parser
containing parser_
followed by lit(rhs)
.
template<parsable_range_like R> constexpr auto operator|(R && r) const noexcept;
Returns a parser_interface
containing a parser equivalent to an or_parser
containing parser_
followed by lit(rhs)
.
template<typename ParserType2> constexpr auto operator-(parser_interface< ParserType2 > rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to !rhs >> *this
.
constexpr auto operator-(char rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to !lit(rhs) >> *this
.
constexpr auto operator-(char32_t rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to !lit(rhs) >> *this
.
template<parsable_range_like R> constexpr auto operator-(R && r) const noexcept;
Returns a parser_interface
containing a parser equivalent to !lit(rhs) >> *this
.
template<typename ParserType2> constexpr auto operator%(parser_interface< ParserType2 > rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to an delimited_seq_parser
containing parser_
and rhs.parser_
.
constexpr auto operator%(char rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to an delimited_seq_parser
containing parser_
and lit(rhs)
.
constexpr auto operator%(char32_t rhs) const noexcept;
Returns a parser_interface
containing a parser equivalent to an delimited_seq_parser
containing parser_
and lit(rhs)
.
template<parsable_range_like R> constexpr auto operator%(R && r) const noexcept;
Returns a parser_interface
containing a parser equivalent to an delimited_seq_parser
containing parser_
and lit(rhs)
.
template<typename Action> constexpr auto operator[](Action action) const;
Returns a parser_interface
containing a parser equivalent to an action_parser
containing parser_
, with semantic action action
.
template<typename Arg, typename... Args> constexpr auto operator()(Arg && arg, Args &&... args) const noexcept;
Returns parser_((Arg &&)arg, (Args &&)args...)
. This is useful for those parsers that have operator()
overloads, e.g. <lsquo></lsquo>char_('x<rsquo></rsquo>)<lsquo></lsquo>. By convention, parsers<rsquo></rsquo> operator()
s return parser_interface
s.
This function does not participate in overload resolution unless parser_((Arg &&)arg, (Args &&)args...)
is well-formed.