3.6.0
|
|
Freundlich's C++ toolkit |
Library for parsers.
Link to fcppt_parse_interface
.
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
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:
A parser is an object with the following properties:
result_type
. 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... | |
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
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.
Parser | A parser whose result is a std::tuple . |