3.6.0
Freundlich's C++ toolkit
Classes | Typedefs | Functions
fcppt.parse

Description

Library for parsers.

Link to fcppt_parse_interface.

Introduction

In a broad sense, a parser gets a string as input and if it belongs to a certain language, produces a specific output. For example, suppose we want to parse numbers of the form [0-9]*, where we allow multiple leading zeroes for simplicity. Each word that belongs to this language should produce a word over the alphabet {0,...,9}. To encode this in C++, we start with an enum of the form

enum class digit
{
_0,
_1,
_2,
_3,
_4,
_5,
_6,
_7,
_8,
_9
};

Next, we create a function that given char c and digit d, it produces a parser that returns d if and only if it gets c as input:

auto make_digit(char const c, digit const d)
{
}

Parser definition

A parser is an object with the following properties:

Classes

class  fcppt::parse::alternative< Left, Right >
 Tries two parsers in succession. Uses the result of the first one that does not fail. More...
 

Typedefs

template<typename Left , typename Right >
using fcppt::parse::alternative_result = fcppt::parse::detail::alternative_result< fcppt::metal::unique< ::metal::join< fcppt::parse::detail::alternative_list< Left >, fcppt::parse::detail::alternative_list< Right > > > >
 The result type of an alternative parser. More...
 

Functions

template<typename Result , typename Parser >
fcppt::parse::convert< fcppt::type_traits::remove_cv_ref_t< Parser >, Result > fcppt::parse::as_struct (Parser &&_parser)
 Creates a parser that converts a tuple into a struct. More...
 

Typedef Documentation

◆ alternative_result

template<typename Left , typename Right >
using fcppt::parse::alternative_result = typedef fcppt::parse::detail::alternative_result< fcppt::metal::unique< ::metal::join< fcppt::parse::detail::alternative_list< Left >, fcppt::parse::detail::alternative_list< Right > > > >

The result type of an alternative parser.

TODO

Function Documentation

◆ as_struct()

template<typename Result , typename Parser >
fcppt::parse::convert< fcppt::type_traits::remove_cv_ref_t< Parser >, Result> fcppt::parse::as_struct ( Parser &&  _parser)

Creates a parser that converts a tuple into a struct.

Template Parameters
ParserA parser whose result is a std::tuple.
fcppt::options::parse
fcppt::options::result< fcppt::options::result_of< Parser >> parse(Parser const &_parser, fcppt::args_vector const &_args)
Parse a command-line.
Definition: parse.hpp:39
fcppt::parse::basic_stream
Definition: basic_stream_decl.hpp:24
fcppt::copy
Type copy(Type const &_value)
Copies a value.
Definition: copy.hpp:27
fcppt::parse::basic_literal
Definition: basic_literal_decl.hpp:27
fcppt::parse::convert_const
Definition: convert_const_decl.hpp:34
fcppt::either::object
Definition: object_decl.hpp:36
fcppt::reference
A simple reference wrapper that supports incomplete types.
Definition: reference_decl.hpp:27