4.6.0
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
fcppt::parse Namespace Reference

Library for parsers. More...

Namespaces

namespace  skipper
 

Classes

class  alternative
 Tries the left parser, and if that fails also the right parser. Uses the result of the first one that does not fail. More...
 
class  alternative_error
 
class  base
 Base class for a parser. More...
 
class  basic_char
 Parses a single character and returns it. More...
 
class  basic_char_error
 
class  basic_char_set
 Parses a set of characters and returns which one has matched. More...
 
class  basic_char_set_error
 
class  basic_literal
 Parses a specific character and returns nothing. More...
 
class  basic_literal_error
 
class  basic_stream
 The stream class used while parsing. More...
 
class  basic_string
 Parses a specific string and returns nothing. More...
 
class  basic_string_error
 
class  complement
 Builds the complement of a fcppt::parse::basic_char_set parser. More...
 
class  complement_error
 
class  convert
 Converts the success value of a parser into another success value. More...
 
class  convert_const
 Replaces the success value of a parser with a constant. More...
 
class  convert_if
 Converts the success value of a parser into either another success value or an error. More...
 
class  custom_error
 
class  epsilon
 Parses the empty string, returns nothing. More...
 
class  error
 The error type. More...
 
class  exclude
 Matches only if another parser does not match. More...
 
class  fail
 Always fails. More...
 
class  fail_error
 
class  fatal
 Makes all error fatal. More...
 
class  float_
 Parses floating-point numbers. More...
 
class  grammar
 Base class for grammars. More...
 
class  ignore
 Ignores the result of a parser. More...
 
class  int_
 Parses signed integers. More...
 
class  lexeme
 Disables the skipper. More...
 
class  list
 Parses lists, e.g., [a_1,...,a_n]. More...
 
class  location
 The location of a fcppt::parse::basic_stream. More...
 
class  named
 Gives a parser a name, improving error messages. More...
 
class  named_error
 
class  not_
 Negates the result of a parser, returns nothing. More...
 
class  optional
 Makes a parser optional. More...
 
class  parse_stream_error
 
class  parse_string_error
 
class  position
 The position of an fcppt::parse::basic_stream. More...
 
class  recursive
 Wraps a type in fcppt::recursive. More...
 
class  repetition
 Tries a parser repeatedly, producing a vector of results. More...
 
class  repetition_plus
 Tries a parser repeatedly, producing a vector of results. Must produce at least one element. More...
 
class  separator
 Parses a list of elements, delimited by a separator, e.g., a_1,...,a_n. More...
 
class  sequence
 Tries two parsers in succession. Produces a tuple of both results if both parsers do not fail. More...
 
struct  tag
 The tag parsers derive from. More...
 
class  typed_error
 
class  uint
 Parses unsigned integers. More...
 
class  with_location
 

Typedefs

template<typename Left , typename Right >
using alternative_result
 The result type of an alternative parser.
 
template<typename Result , typename Ch , typename Skipper >
using base_unique_ptr = fcppt::unique_ptr<fcppt::parse::base<Result, Ch, Skipper>>
 unique_ptr to fcppt::parse::base
 
template<typename Ch >
using basic_char_set_container = std::unordered_set<Ch>
 The character set type.
 
using char_ = fcppt::parse::basic_char<char>
 
using char_set = fcppt::parse::basic_char_set<char>
 
using column = fcppt::strong_typedef< std::uint64_t ,_>
 The column type of a position.
 
template<typename Parser >
using deref_type = std::remove_cvref_t<fcppt::deref_type<Parser const>>
 The dereferenced type of a parser.
 
template<typename Ch >
using error_variant
 
template<typename Type >
using is_char = std::disjunction<std::is_same<Type, char>, std::is_same<Type, wchar_t>>
 The allowed char types, currently char and wchar_t.
 
using is_fatal = fcppt::strong_typedef< bool ,_>
 
template<typename Type >
using is_parser = std::is_base_of<fcppt::parse::tag, Type>
 Checks if a type is a parser.A type is a parser if and only if it derives from fcppt::parse::tag.
 
template<typename Type >
using is_valid_argument
 Checks if a parameter is a valid parser type.
 
using line = fcppt::strong_typedef< std::uint64_t ,_>
 The line type of a position.
 
using literal = fcppt::parse::basic_literal<char>
 
template<typename Type >
using repetition_result
 The result type of a repetition parser.
 
template<typename Ch , typename Type >
using result = fcppt::either::object<fcppt::parse::error<Ch>, Type>
 The result type when parsing streams of Ch, producing values of Type.The result is an fcppt::either::object of fcppt::parse::error<Ch> and Type.
 
template<typename Parser >
using result_of = typename fcppt::parse::deref_type<Parser>::result_type
 The result type of a parser.
 
template<typename Left , typename Right >
using sequence_result
 The result of a sequence parser.
 
using string = fcppt::parse::basic_string<char>
 

Functions

template<typename Result , typename Parser >
requires (fcppt::tuple::is_object<fcppt::parse::result_of<Parser>>::value)
fcppt::parse::convert< std::remove_cvref_t< Parser >, Result > as_struct (Parser &&_parser)
 Creates a parser that converts a tuple into a struct.
 
fcppt::parse::char_set blank ()
 Parser that parses blank characters.
 
template<typename Ch >
fcppt::parse::basic_char_set_container< Ch > blank_set ()
 The set of blank characters.
 
template<typename Result , typename Parser >
fcppt::parse::convert< std::remove_cvref_t< Parser >, Result > construct (Parser &&_parser)
 Applies a constructor to the result of a parser.
 
template<typename Parser , typename Result >
FCPPT_PP_POP_WARNING convert_const (Parser &&, Result &&) -> convert_const< std::remove_cvref_t< Parser >, std::remove_cvref_t< Result > >
 
template<typename Parser >
fcppt::parse::deref_type< Parser > const & deref (Parser const &_parser)
 Dereferences a parser.
 
template<typename Ch >
fcppt::parse::basic_char_set< Ch > digits ()
 The char set of digits.
 
template<typename Ch >
std::basic_ostream< Ch > & operator<< (std::basic_ostream< Ch > &_stream, fcppt::parse::error< Ch > const &_error)
 
template<typename Ch >
fcppt::optional::object< Ch > get_char (fcppt::reference< fcppt::parse::basic_stream< Ch > > const _state)
 The next character in a stream.
 
template<typename Ch >
fcppt::parse::position< Ch > get_position (fcppt::reference< fcppt::parse::basic_stream< Ch > > const _state)
 The current position of a stream.
 
template<typename Result , typename Ch , typename Skipper >
fcppt::either::object< fcppt::parse::parse_stream_error< Ch >, Result > grammar_parse_stream (std::basic_istream< Ch > &_stream, fcppt::parse::grammar< Result, Ch, Skipper > const &_grammar)
 Parse a stream using a grammar.
 
template<typename Result , typename Ch , typename Skipper >
fcppt::either::object< fcppt::parse::parse_string_error< Ch >, Result > grammar_parse_string (std::basic_string< Ch > &&_string, fcppt::parse::grammar< Result, Ch, Skipper > const &_grammar)
 Parse a string using a grammar.
 
template<typename Start , typename Inner , typename Sep , typename End >
FCPPT_PP_POP_WARNING list (Start &&, Inner &&, Sep &&, End &&) -> list< std::remove_cvref_t< Start >, std::remove_cvref_t< Inner >, std::remove_cvref_t< Sep >, std::remove_cvref_t< End > >
 
bool operator== (fcppt::parse::location const &_left, fcppt::parse::location const &_right)
 
template<typename Ch , typename Traits >
std::basic_ostream< Ch, Traits > & operator<< (std::basic_ostream< Ch, Traits > &_stream, fcppt::parse::location const &_loc)
 Outputs a location to a stream.
 
template<typename Ch , typename Skipper , typename Parser >
fcppt::parse::base_unique_ptr< fcppt::parse::result_of< Parser >, Ch, Skipper > make_base (Parser &&_parser)
 Hides the type of a parser, turning it into an fcppt::parse::base_unique_ptr.
 
template<typename Parser , typename Convert >
fcppt::parse::convert< std::remove_cvref_t< Parser >, std::invoke_result_t< Convert, fcppt::parse::result_of< Parser > && > > make_convert (Parser &&_parser, Convert &&_convert)
 Creates an fcppt::parse::convert parser out of a lambda.
 
template<typename Ch , typename Parser , typename Convert >
fcppt::parse::convert_if< Ch, std::remove_cvref_t< Parser >, fcppt::either::success_type< std::invoke_result_t< Convert, fcppt::parse::position< Ch >, fcppt::parse::result_of< Parser > && > > > make_convert_if (Parser &&_parser, Convert &&_convert)
 Creates an fcppt::parse::convert_if parser out of a lambda.
 
template<typename Parser >
fcppt::parse::fatal< std::remove_cvref_t< Parser > > make_fatal (Parser &&_parser)
 Creates an fcppt::parse::fatal parser.
 
template<typename Parser >
fcppt::parse::ignore< std::remove_cvref_t< Parser > > make_ignore (Parser &&_parser)
 Creates an fcppt::parse::ignore parser.
 
template<typename Parser >
fcppt::parse::lexeme< std::remove_cvref_t< Parser > > make_lexeme (Parser &&_parser)
 Creates an fcppt::parse::lexeme parser.
 
template<typename Ch >
fcppt::parse::basic_literal< Ch > make_literal (Ch const _ch)
 Creates an fcppt::parse::basic_literal parser.
 
template<typename Ch , typename Success >
fcppt::either::object< fcppt::parse::parse_stream_error< Ch >, std::remove_cvref_t< Success > > make_parse_stream_success (Success &&_success)
 Creates a success value with a parse_stream failure type.
 
template<typename Ch , typename Success >
fcppt::either::object< fcppt::parse::parse_string_error< Ch >, std::remove_cvref_t< Success > > make_parse_string_success (Success &&_success)
 Creates a success value with a parse_string failure type.
 
template<typename Parser >
fcppt::parse::recursive< std::remove_cvref_t< Parser > > make_recursive (Parser &&_parser)
 Creates an fcppt::parse::recursive parser.
 
template<typename Ch , typename Success >
fcppt::parse::result< Ch, std::remove_cvref_t< Success > > make_success (Success &&_success)
 Creates an fcppt::parse::result from a success value.
 
template<typename Parser >
fcppt::parse::with_location< std::remove_cvref_t< Parser > > make_with_location (Parser &&_parser)
 Creates an fcppt::parse::with_location parser.
 
template<typename Ch , typename Parser >
FCPPT_PP_POP_WARNING named (Parser &&, std::basic_string< Ch > &&) -> named< Ch, std::remove_cvref_t< Parser > >
 
template<typename Left , typename Right >
requires (std::conjunction_v< fcppt::parse::is_valid_argument<Left>, fcppt::parse::is_valid_argument<Right>>)
fcppt::parse::alternative< std::remove_cvref_t< Left >, std::remove_cvref_t< Right > > operator| (Left &&_left, Right &&_right)
 Creates an fcppt::parse::alternative parser.
 
template<typename Parser >
requires (fcppt::parse::detail::is_char_set<fcppt::parse::deref_type<Parser>>::value)
auto operator~ (Parser &&_parser)
 Creates an fcppt::parse::complement parser.
 
template<typename Left , typename Right >
requires (std::conjunction_v< fcppt::parse::is_valid_argument<Left>, fcppt::parse::is_valid_argument<Right>>)
fcppt::parse::exclude< std::remove_cvref_t< Left >, std::remove_cvref_t< Right > > operator- (Left &&_left, Right &&_right)
 Creates an fcppt::parse::exclude parser.
 
template<typename Parser >
requires (fcppt::parse::is_valid_argument<Parser>::value)
fcppt::parse::not_< std::remove_cvref_t< Parser > > operator! (Parser &&_parser)
 Creates an fcppt::parse::not_ parser.
 
template<typename Parser >
requires (fcppt::parse::is_valid_argument<Parser>::value)
fcppt::parse::optional< std::remove_cvref_t< Parser > > operator- (Parser &&_parser)
 Creates an fcppt::parse::optional parser.
 
template<typename Parser >
requires (fcppt::parse::is_valid_argument<Parser>::value)
fcppt::parse::repetition< std::remove_cvref_t< Parser > > operator* (Parser &&_parser)
 Creates an fcppt::parse::repetition parser.
 
template<typename Parser >
requires (fcppt::parse::is_valid_argument<Parser>::value)
fcppt::parse::repetition_plus< std::remove_cvref_t< Parser > > operator+ (Parser &&_parser)
 Creates an fcppt::parse::repetition_plus parser.
 
template<typename Left , typename Right >
requires (std::conjunction_v< fcppt::parse::is_valid_argument<Left>, fcppt::parse::is_valid_argument<Right>>)
fcppt::parse::sequence< std::remove_cvref_t< Left >, std::remove_cvref_t< Right > > operator>> (Left &&_left, Right &&_right)
 Creates an fcppt::parse::sequence parser.
 
template<typename Ch , typename Parser >
fcppt::either::object< fcppt::parse::parse_stream_error< Ch >, fcppt::parse::result_of< Parser > > parse (Parser const &_parser, fcppt::parse::basic_stream< Ch > &_input)
 Parses without whitespace skipping.
 
template<typename Ch , typename Parser >
fcppt::either::object< fcppt::parse::parse_stream_error< Ch >, fcppt::parse::result_of< Parser > > parse_stream (Parser const &_parser, std::basic_istream< Ch > &_input)
 Parses a std::basic_istream without whitespace skipping.
 
template<typename Ch >
std::basic_ostream< Ch > & operator<< (std::basic_ostream< Ch > &_stream, fcppt::parse::parse_stream_error< Ch > const &_error)
 
template<typename Ch , typename Parser >
fcppt::either::object< fcppt::parse::parse_string_error< Ch >, fcppt::parse::result_of< Parser > > parse_string (Parser const &_parser, std::basic_string< Ch > &&_string)
 Parses a std::basic_string without whitespace skipping.
 
template<typename Ch >
std::basic_ostream< Ch > & operator<< (std::basic_ostream< Ch > &_stream, fcppt::parse::parse_string_error< Ch > const &_error)
 
template<typename Ch , typename Parser , typename Skipper >
requires (std::conjunction_v< fcppt::parse::is_parser<Parser>, fcppt::parse::skipper::is_skipper<Skipper>>)
fcppt::either::object< fcppt::parse::parse_stream_error< Ch >, fcppt::parse::result_of< Parser > > phrase_parse (Parser const &_parser, fcppt::parse::basic_stream< Ch > &_input, Skipper const &_skipper)
 The basic parse function.
 
template<typename Ch , typename Parser , typename Skipper >
requires (std::conjunction_v< fcppt::parse::is_parser<Parser>, fcppt::parse::skipper::is_skipper<Skipper>>)
fcppt::either::object< fcppt::parse::parse_stream_error< Ch >, fcppt::parse::result_of< Parser > > phrase_parse_stream (Parser const &_parser, std::basic_istream< Ch > &_input, Skipper const &_skipper)
 Parses a std::basic_istream, using whitespace skipping.
 
template<typename Ch , typename Parser , typename Skipper >
requires (std::conjunction_v< fcppt::parse::is_parser<Parser>, fcppt::parse::skipper::is_skipper<Skipper>>)
fcppt::either::object< fcppt::parse::parse_string_error< Ch >, fcppt::parse::result_of< Parser > > phrase_parse_string (Parser const &_parser, std::basic_string< Ch > &&_string, Skipper const &_skipper)
 Parses a std::basic_string, using whitespace skipping.
 
template<typename Ch >
bool operator== (fcppt::parse::position< Ch > const &_left, fcppt::parse::position< Ch > const &_right)
 Compares two positions for equality.
 
template<typename Ch >
std::basic_ostream< Ch > & operator<< (std::basic_ostream< Ch > &_stream, fcppt::parse::position< Ch > const &_pos)
 Outputs a position to a stream.
 
template<typename Inner , typename Sep >
FCPPT_PP_POP_WARNING separator (Inner &&, Sep &&) -> separator< std::remove_cvref_t< Inner >, std::remove_cvref_t< Sep > >
 
template<typename Ch >
void set_position (fcppt::reference< fcppt::parse::basic_stream< Ch > > const _state, fcppt::parse::position< Ch > const _pos)
 Sets the current position of a stream.
 
fcppt::parse::char_set space ()
 The char set parser using fcppt::parse::space_set<char>.
 
template<typename Ch >
fcppt::parse::basic_char_set_container< Ch > space_set ()
 The char set of spaces.Returns the set containing the whitespace, newline and tab characters.
 

Detailed Description

Library for parsers.

Typedef Documentation

◆ error_variant

◆ is_fatal

Function Documentation

◆ convert_const()

template<typename Parser , typename Result >
FCPPT_PP_POP_WARNING fcppt::parse::convert_const ( Parser && ,
Result &&  ) -> convert_const< std::remove_cvref_t< Parser >, std::remove_cvref_t< Result > >

◆ list()

template<typename Start , typename Inner , typename Sep , typename End >
FCPPT_PP_POP_WARNING fcppt::parse::list ( Start && ,
Inner && ,
Sep && ,
End &&  ) -> list< std::remove_cvref_t< Start >, std::remove_cvref_t< Inner >, std::remove_cvref_t< Sep >, std::remove_cvref_t< End > >

◆ named()

template<typename Ch , typename Parser >
FCPPT_PP_POP_WARNING fcppt::parse::named ( Parser && ,
std::basic_string< Ch > &&  ) -> named< Ch, std::remove_cvref_t< Parser > >

◆ operator<<() [1/3]

template<typename Ch >
std::basic_ostream< Ch > & fcppt::parse::operator<< ( std::basic_ostream< Ch > & _stream,
fcppt::parse::error< Ch > const & _error )

◆ operator<<() [2/3]

template<typename Ch >
std::basic_ostream< Ch > & fcppt::parse::operator<< ( std::basic_ostream< Ch > & _stream,
fcppt::parse::parse_stream_error< Ch > const & _error )

◆ operator<<() [3/3]

template<typename Ch >
std::basic_ostream< Ch > & fcppt::parse::operator<< ( std::basic_ostream< Ch > & _stream,
fcppt::parse::parse_string_error< Ch > const & _error )

◆ operator==()

bool fcppt::parse::operator== ( fcppt::parse::location const & _left,
fcppt::parse::location const & _right )
inlinenodiscard

◆ separator()

template<typename Inner , typename Sep >
FCPPT_PP_POP_WARNING fcppt::parse::separator ( Inner && ,
Sep &&  ) -> separator< std::remove_cvref_t< Inner >, std::remove_cvref_t< Sep > >