4.2.0
Freundlich's C++ toolkit
Namespaces | Classes | Typedefs | Functions
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  base
 Base class for a parser. More...
 
class  basic_char
 Parses a single character and returns it. More...
 
class  basic_char_set
 Parses a set of characters and returns which one has matched. More...
 
class  basic_literal
 Parses a specific character and returns nothing. More...
 
class  basic_stream
 The stream class used while parsing. More...
 
class  basic_string
 Parses a specific string and returns nothing. More...
 
class  complement
 Builds the complement of a fcppt::parse::basic_char_set parser. More...
 
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  epsilon
 Parses the empty string, returns nothing. More...
 
class  error
 The error type. More...
 
class  fail
 Always fails. More...
 
class  fatal
 Makes all error fatal. More...
 
struct  fatal_tag
 Used to disambiguate constructors of fcppt::parse::error. 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  not_
 Negates the result of a parser, returns nothing. More...
 
class  optional
 Makes a parser optional. More...
 
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  uint
 Parses unsigned integers. More...
 
class  with_location
 

Typedefs

template<typename Left , typename Right >
using alternative_result = fcppt::parse::detail::alternative_result< fcppt::mpl::list::unique< fcppt::mpl::list::append< fcppt::parse::detail::alternative_list< Left >, fcppt::parse::detail::alternative_list< Right > > > >
 The result type of an alternative parser. More...
 
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 More...
 
template<typename Ch >
using basic_char_set_container = std::unordered_set< Ch >
 The character set type. More...
 
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. More...
 
template<typename Parser >
using deref_type = std::remove_cvref_t< fcppt::deref_type< Parser const > >
 The dereferenced type of a parser. More...
 
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. More...
 
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. More...
 
template<typename Type >
using is_valid_argument = fcppt::parse::is_parser< fcppt::parse::deref_type< std::remove_cvref_t< Type > > >
 Checks if a parameter is a valid parser type. More...
 
using line = fcppt::strong_typedef< std::uint64_t,_ >
 The line type of a position. More...
 
using literal = fcppt::parse::basic_literal< char >
 
template<typename Type >
using repetition_result = std::conditional_t< fcppt::parse::is_char< Type >::value, std::basic_string< Type >, std::vector< Type > >
 The result type of a repetition parser. More...
 
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. More...
 
template<typename Parser >
using result_of = typename fcppt::parse::deref_type< Parser >::result_type
 The result type of a parser. More...
 
template<typename Left , typename Right >
using sequence_result = decltype(fcppt::parse::detail::sequence_result(std::declval< Left >(), std::declval< Right >()))
 The result of a sequence parser. More...
 
using string = fcppt::parse::basic_string< char >
 

Functions

template<typename Result , typename Parser , typename = std::enable_if_t<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. More...
 
fcppt::parse::char_set blank ()
 Parser that parses blank characters. More...
 
template<typename Ch >
fcppt::parse::basic_char_set_container< Ch > blank_set ()
 The set of blank characters. More...
 
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. More...
 
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. More...
 
template<typename Ch >
fcppt::parse::basic_char_set< Ch > digits ()
 The char set of digits. More...
 
template<typename Ch >
fcppt::parse::error< Ch > operator+ (fcppt::parse::error< Ch > &&_left, fcppt::parse::error< Ch > &&_right)
 Adds two errors. More...
 
template<typename Ch >
bool operator== (fcppt::parse::error< Ch > const &_left, fcppt::parse::error< Ch > const &_right)
 
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. More...
 
template<typename Ch >
fcppt::parse::result< Ch, Ch > get_char_error (fcppt::reference< fcppt::parse::basic_stream< Ch > > const _state)
 The next character in a stream. Returns the error message "EOF" on failure. More...
 
template<typename Ch >
fcppt::parse::position< Ch > get_position (fcppt::reference< fcppt::parse::basic_stream< Ch > > const _state)
 The current position of a stream. More...
 
template<typename Result , typename Ch , typename Skipper >
fcppt::parse::result< Ch, Result > grammar_parse_stream (std::basic_istream< Ch > &_stream, fcppt::parse::grammar< Result, Ch, Skipper > const &_grammar)
 Parse a stream using a grammar. More...
 
template<typename Result , typename Ch , typename Skipper >
fcppt::parse::result< Ch, Result > grammar_parse_string (std::basic_string< Ch > &&_string, fcppt::parse::grammar< Result, Ch, Skipper > const &_grammar)
 Parse a string using a grammar. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename Parser , typename Convert >
fcppt::parse::convert_if< fcppt::type_traits::value_type< fcppt::type_traits::value_type< fcppt::either::failure_type< std::invoke_result_t< Convert, fcppt::parse::result_of< Parser > && > > > >, std::remove_cvref_t< Parser >, fcppt::either::success_type< std::invoke_result_t< Convert, fcppt::parse::result_of< Parser > && > > > make_convert_if (Parser &&_parser, Convert &&_convert)
 Creates an fcppt::parse::convert_if parser out of a lambda. More...
 
template<typename Parser >
fcppt::parse::fatal< std::remove_cvref_t< Parser > > make_fatal (Parser &&_parser)
 Creates an fcppt::parse::fatal parser. More...
 
template<typename Parser >
fcppt::parse::ignore< std::remove_cvref_t< Parser > > make_ignore (Parser &&_parser)
 Creates an fcppt::parse::ignore parser. More...
 
template<typename Parser >
fcppt::parse::lexeme< std::remove_cvref_t< Parser > > make_lexeme (Parser &&_parser)
 Creates an fcppt::parse::lexeme parser. More...
 
template<typename Ch >
fcppt::parse::basic_literal< Ch > make_literal (Ch const _ch)
 Creates an fcppt::parse::basic_literal parser. More...
 
template<typename Parser >
fcppt::parse::recursive< std::remove_cvref_t< Parser > > make_recursive (Parser &&_parser)
 Creates an fcppt::parse::recursive parser. More...
 
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. More...
 
template<typename Parser >
fcppt::parse::with_location< std::remove_cvref_t< Parser > > make_with_location (Parser &&_parser)
 Creates an fcppt::parse::with_location parser. More...
 
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 , typename = std::enable_if_t<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. More...
 
template<typename Parser , typename = std::enable_if_t< fcppt::parse::detail::is_char_set<fcppt::parse::deref_type<Parser>>::value>>
auto operator~ (Parser &&_parser)
 Creates an fcppt::parse::complement parser. More...
 
template<typename Parser , typename = std::enable_if_t<fcppt::parse::is_valid_argument<Parser>::value>>
fcppt::parse::not_< std::remove_cvref_t< Parser > > operator! (Parser &&_parser)
 Creates an fcppt::parse::not_ parser. More...
 
template<typename Parser , typename = std::enable_if_t<fcppt::parse::is_valid_argument<Parser>::value>>
fcppt::parse::optional< std::remove_cvref_t< Parser > > operator- (Parser &&_parser)
 Creates an fcppt::parse::optional parser. More...
 
template<typename Parser , typename = std::enable_if_t<fcppt::parse::is_valid_argument<Parser>::value>>
fcppt::parse::repetition< std::remove_cvref_t< Parser > > operator* (Parser &&_parser)
 Creates an fcppt::parse::repetition parser. More...
 
template<typename Parser , typename = std::enable_if_t<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. More...
 
template<typename Left , typename Right , typename = std::enable_if_t<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. More...
 
template<typename Ch , typename Parser >
fcppt::parse::result< Ch, fcppt::parse::result_of< Parser > > parse (Parser const &_parser, fcppt::parse::basic_stream< Ch > &_input)
 Parses without whitespace skipping. More...
 
template<typename Ch , typename Parser , typename Skipper >
fcppt::parse::result< Ch, fcppt::parse::result_of< Parser > > parse_stream (Parser const &_parser, std::basic_istream< Ch > &_input)
 Parses a std::basic_istream without whitespace skipping. More...
 
template<typename Ch , typename Parser >
fcppt::parse::result< Ch, fcppt::parse::result_of< Parser > > parse_string (Parser const &_parser, std::basic_string< Ch > &&_string)
 Parses a std::basic_string without whitespace skipping. More...
 
template<typename Ch , typename Parser , typename Skipper , typename = std::enable_if_t<std::conjunction_v< fcppt::parse::is_parser<Parser>, fcppt::parse::skipper::is_skipper<Skipper>>>>
fcppt::parse::result< Ch, fcppt::parse::result_of< Parser > > phrase_parse (Parser const &_parser, fcppt::parse::basic_stream< Ch > &_input, Skipper const &_skipper)
 The basic parse function. More...
 
template<typename Ch , typename Parser , typename Skipper , typename = std::enable_if_t<std::conjunction_v< fcppt::parse::is_parser<Parser>, fcppt::parse::skipper::is_skipper<Skipper>>>>
fcppt::parse::result< 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. More...
 
template<typename Ch , typename Parser , typename Skipper , typename = std::enable_if_t<std::conjunction_v< fcppt::parse::is_parser<Parser>, fcppt::parse::skipper::is_skipper<Skipper>>>>
fcppt::parse::result< 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. More...
 
template<typename Ch >
bool operator== (fcppt::parse::position< Ch > const &_left, fcppt::parse::position< Ch > const &_right)
 Compares two positions for equality. More...
 
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. More...
 
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. More...
 
fcppt::parse::char_set space ()
 The char set parser using fcppt::parse::space_set<char>. More...
 
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. More...
 

Detailed Description

Library for parsers.

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<<()

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

◆ operator==() [1/2]

template<typename Ch >
bool fcppt::parse::operator== ( fcppt::parse::error< Ch > const &  _left,
fcppt::parse::error< Ch > const &  _right 
)

◆ operator==() [2/2]

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

◆ 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 > >