diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/metaparse/example/getting_started | |
parent | Initial commit. (diff) | |
download | ceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.tar.xz ceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/metaparse/example/getting_started')
39 files changed, 1022 insertions, 0 deletions
diff --git a/src/boost/libs/metaparse/example/getting_started/1.hpp b/src/boost/libs/metaparse/example/getting_started/1.hpp new file mode 100644 index 000000000..ee00e7a1d --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/1.hpp @@ -0,0 +1,9 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_1_HPP +#define BOOST_METAPARSE_GETTING_STARTED_1_HPP + +// Automatically generated header file + +// Definitions of section + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/10.hpp b/src/boost/libs/metaparse/example/getting_started/10.hpp new file mode 100644 index 000000000..e8ed5f1c3 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/10.hpp @@ -0,0 +1,42 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_10_HPP +#define BOOST_METAPARSE_GETTING_STARTED_10_HPP + +// Automatically generated header file + +// Definitions before section 9 +#include "9.hpp" + +// Definitions of section 9 +#include <boost/mpl/negate.hpp> + +using unary_exp1 = + foldr_start_with_parser< + minus_token, + int_token, + boost::mpl::lambda<boost::mpl::negate<boost::mpl::_1>>::type + >; + +using mult_exp4 = + foldl_start_with_parser< + sequence<one_of<times_token, divides_token>, unary_exp1>, + unary_exp1, + boost::mpl::quote2<binary_op> + >; + +using exp_parser18 = + build_parser< + foldl_start_with_parser< + sequence<one_of<plus_token, minus_token>, mult_exp4>, + mult_exp4, + boost::mpl::quote2<binary_op> + > + >; + +// query: +// exp_parser18::apply<BOOST_METAPARSE_STRING("---13")>::type + +// query: +// exp_parser18::apply<BOOST_METAPARSE_STRING("13")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/11.hpp b/src/boost/libs/metaparse/example/getting_started/11.hpp new file mode 100644 index 000000000..3583496a8 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/11.hpp @@ -0,0 +1,62 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_11_HPP +#define BOOST_METAPARSE_GETTING_STARTED_11_HPP + +// Automatically generated header file + +// Definitions before section 10 +#include "10.hpp" + +// Definitions of section 10 +using lparen_token = token<lit_c<'('>>; + +using rparen_token = token<lit_c<')'>>; + +using plus_exp1 = + foldl_start_with_parser< + sequence<one_of<plus_token, minus_token>, mult_exp4>, + mult_exp4, + boost::mpl::quote2<binary_op> + >; + +using paren_exp1 = sequence<lparen_token, plus_exp1, rparen_token>; + +#include <boost/metaparse/middle_of.hpp> + +using paren_exp2 = middle_of<lparen_token, plus_exp1, rparen_token>; + +using primary_exp1 = one_of<int_token, paren_exp2>; + +struct plus_exp2; + +using paren_exp3 = middle_of<lparen_token, plus_exp2, rparen_token>; + +using primary_exp2 = one_of<int_token, paren_exp2>; + +using unary_exp2 = + foldr_start_with_parser< + minus_token, + primary_exp2, + boost::mpl::lambda<boost::mpl::negate<boost::mpl::_1>>::type + >; + +using mult_exp5 = + foldl_start_with_parser< + sequence<one_of<times_token, divides_token>, unary_exp2>, + unary_exp2, + boost::mpl::quote2<binary_op> + >; + +struct plus_exp2 : + foldl_start_with_parser< + sequence<one_of<plus_token, minus_token>, mult_exp5>, + mult_exp5, + boost::mpl::quote2<binary_op> + > {}; + +using exp_parser19 = build_parser<plus_exp2>; + +// query: +// exp_parser19::apply<BOOST_METAPARSE_STRING("(1 + 2) * 3")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/11_1.hpp b/src/boost/libs/metaparse/example/getting_started/11_1.hpp new file mode 100644 index 000000000..be2a2de63 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/11_1.hpp @@ -0,0 +1,14 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_11_1_HPP +#define BOOST_METAPARSE_GETTING_STARTED_11_1_HPP + +// Automatically generated header file + +// Definitions before section 11 +#include "11.hpp" + +// Definitions of section 11 +// query: +// exp_parser19::apply<BOOST_METAPARSE_STRING("hello")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/11_2.hpp b/src/boost/libs/metaparse/example/getting_started/11_2.hpp new file mode 100644 index 000000000..ae36b4e46 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/11_2.hpp @@ -0,0 +1,12 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_11_2_HPP +#define BOOST_METAPARSE_GETTING_STARTED_11_2_HPP + +// Automatically generated header file + +// Definitions before section 11.1 +#include "11_1.hpp" + +// Definitions of section 11.1 + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/11_3.hpp b/src/boost/libs/metaparse/example/getting_started/11_3.hpp new file mode 100644 index 000000000..a93c2dc47 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/11_3.hpp @@ -0,0 +1,49 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_11_3_HPP +#define BOOST_METAPARSE_GETTING_STARTED_11_3_HPP + +// Automatically generated header file + +// Definitions before section 11.2 +#include "11_2.hpp" + +// Definitions of section 11.2 +#include <boost/metaparse/define_error.hpp> + +BOOST_METAPARSE_DEFINE_ERROR(missing_primary_expression, "Missing primary expression"); + +struct plus_exp3; + +using paren_exp4 = middle_of<lparen_token, plus_exp3, rparen_token>; + +#include <boost/metaparse/fail.hpp> + +using primary_exp3 = one_of<int_token, paren_exp4, fail<missing_primary_expression>>; + +using unary_exp3 = + foldr_start_with_parser< + minus_token, + primary_exp3, + boost::mpl::lambda<boost::mpl::negate<boost::mpl::_1>>::type + >; + +using mult_exp6 = + foldl_start_with_parser< + sequence<one_of<times_token, divides_token>, unary_exp3>, + unary_exp3, + boost::mpl::quote2<binary_op> + >; + +struct plus_exp3 : + foldl_start_with_parser< + sequence<one_of<plus_token, minus_token>, mult_exp6>, + mult_exp6, + boost::mpl::quote2<binary_op> + > {}; + +using exp_parser20 = build_parser<plus_exp3>; + +// query: +// exp_parser20::apply<BOOST_METAPARSE_STRING("hello")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/11_3_1.hpp b/src/boost/libs/metaparse/example/getting_started/11_3_1.hpp new file mode 100644 index 000000000..56da35a82 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/11_3_1.hpp @@ -0,0 +1,38 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_11_3_1_HPP +#define BOOST_METAPARSE_GETTING_STARTED_11_3_1_HPP + +// Automatically generated header file + +// Definitions before section 11.3 +#include "11_3.hpp" + +// Definitions of section 11.3 +// query: +// exp_parser20::apply<BOOST_METAPARSE_STRING("(1+2")>::type + +// query: +// exp_parser20::apply<BOOST_METAPARSE_STRING("0+(1+2")>::type + +#include <boost/metaparse/fail_at_first_char_expected.hpp> + +#include <boost/metaparse/first_of.hpp> + +struct plus_exp4 : + first_of< + foldl_start_with_parser< + sequence<one_of<plus_token, minus_token>, mult_exp6>, + mult_exp6, + boost::mpl::quote2<binary_op> + >, + fail_at_first_char_expected< + sequence<one_of<plus_token, minus_token>, mult_exp6> + > + > {}; + +using exp_parser21 = build_parser<plus_exp4>; + +// query: +// exp_parser21::apply<BOOST_METAPARSE_STRING("0+(1+2")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/11_3_2.hpp b/src/boost/libs/metaparse/example/getting_started/11_3_2.hpp new file mode 100644 index 000000000..bf2e4b457 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/11_3_2.hpp @@ -0,0 +1,25 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_11_3_2_HPP +#define BOOST_METAPARSE_GETTING_STARTED_11_3_2_HPP + +// Automatically generated header file + +// Definitions before section 11.3.1 +#include "11_3_1.hpp" + +// Definitions of section 11.3.1 +#include <boost/metaparse/foldl_reject_incomplete_start_with_parser.hpp> + +struct plus_exp5 : + foldl_reject_incomplete_start_with_parser< + sequence<one_of<plus_token, minus_token>, mult_exp6>, + mult_exp6, + boost::mpl::quote2<binary_op> + > {}; + +using exp_parser22 = build_parser<plus_exp5>; + +// query: +// exp_parser22::apply<BOOST_METAPARSE_STRING("0+(1+2")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/12.hpp b/src/boost/libs/metaparse/example/getting_started/12.hpp new file mode 100644 index 000000000..d503539b1 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/12.hpp @@ -0,0 +1,46 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_12_HPP +#define BOOST_METAPARSE_GETTING_STARTED_12_HPP + +// Automatically generated header file + +// Definitions before section 11.3.2 +#include "11_3_2.hpp" + +// Definitions of section 11.3.2 +struct plus_exp6; + +using paren_exp5 = middle_of<lparen_token, plus_exp6, rparen_token>; + +using primary_exp4 = one_of<int_token, paren_exp5, fail<missing_primary_expression>>; + +using unary_exp4 = + foldr_start_with_parser< + minus_token, + primary_exp4, + boost::mpl::lambda<boost::mpl::negate<boost::mpl::_1>>::type + >; + +using mult_exp7 = + foldl_reject_incomplete_start_with_parser< + sequence<one_of<times_token, divides_token>, unary_exp4>, + unary_exp4, + boost::mpl::quote2<binary_op> + >; + +struct plus_exp6 : + foldl_reject_incomplete_start_with_parser< + sequence<one_of<plus_token, minus_token>, mult_exp7>, + mult_exp7, + boost::mpl::quote2<binary_op> + > {}; + +using exp_parser23 = build_parser<plus_exp6>; + +// query: +// exp_parser23::apply<BOOST_METAPARSE_STRING("1+(2*")>::type + +// query: +// exp_parser23::apply<BOOST_METAPARSE_STRING("1+(2*3")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/1_1.hpp b/src/boost/libs/metaparse/example/getting_started/1_1.hpp new file mode 100644 index 000000000..36fa44660 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/1_1.hpp @@ -0,0 +1,12 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_1_1_HPP +#define BOOST_METAPARSE_GETTING_STARTED_1_1_HPP + +// Automatically generated header file + +// Definitions before section 1 +#include "1.hpp" + +// Definitions of section 1 + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/1_2.hpp b/src/boost/libs/metaparse/example/getting_started/1_2.hpp new file mode 100644 index 000000000..dd19e3ef9 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/1_2.hpp @@ -0,0 +1,12 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_1_2_HPP +#define BOOST_METAPARSE_GETTING_STARTED_1_2_HPP + +// Automatically generated header file + +// Definitions before section 1.1 +#include "1_1.hpp" + +// Definitions of section 1.1 + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/1_2_1.hpp b/src/boost/libs/metaparse/example/getting_started/1_2_1.hpp new file mode 100644 index 000000000..db5d3fe53 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/1_2_1.hpp @@ -0,0 +1,12 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_1_2_1_HPP +#define BOOST_METAPARSE_GETTING_STARTED_1_2_1_HPP + +// Automatically generated header file + +// Definitions before section 1.2 +#include "1_2.hpp" + +// Definitions of section 1.2 + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/1_2_2.hpp b/src/boost/libs/metaparse/example/getting_started/1_2_2.hpp new file mode 100644 index 000000000..f84edb36c --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/1_2_2.hpp @@ -0,0 +1,12 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_1_2_2_HPP +#define BOOST_METAPARSE_GETTING_STARTED_1_2_2_HPP + +// Automatically generated header file + +// Definitions before section 1.2.1 +#include "1_2_1.hpp" + +// Definitions of section 1.2.1 + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/2.hpp b/src/boost/libs/metaparse/example/getting_started/2.hpp new file mode 100644 index 000000000..3c3ecb422 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/2.hpp @@ -0,0 +1,12 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_2_HPP +#define BOOST_METAPARSE_GETTING_STARTED_2_HPP + +// Automatically generated header file + +// Definitions before section 1.2.2 +#include "1_2_2.hpp" + +// Definitions of section 1.2.2 + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/3.hpp b/src/boost/libs/metaparse/example/getting_started/3.hpp new file mode 100644 index 000000000..4df3b531d --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/3.hpp @@ -0,0 +1,19 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_3_HPP +#define BOOST_METAPARSE_GETTING_STARTED_3_HPP + +// Automatically generated header file + +// Definitions before section 2 +#include "2.hpp" + +// Definitions of section 2 +#include <boost/metaparse/string.hpp> + +// query: +// boost::metaparse::string<'1', '1', ' ', '+', ' ', '2'> + +// query: +// BOOST_METAPARSE_STRING("11 + 2") + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/3_1.hpp b/src/boost/libs/metaparse/example/getting_started/3_1.hpp new file mode 100644 index 000000000..f383508db --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/3_1.hpp @@ -0,0 +1,22 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_3_1_HPP +#define BOOST_METAPARSE_GETTING_STARTED_3_1_HPP + +// Automatically generated header file + +// Definitions before section 3 +#include "3.hpp" + +// Definitions of section 3 +#include <boost/metaparse/int_.hpp> + +#include <boost/metaparse/build_parser.hpp> + +using namespace boost::metaparse; + +using exp_parser1 = build_parser<int_>; + +// query: +// exp_parser1::apply<BOOST_METAPARSE_STRING("13")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/3_2.hpp b/src/boost/libs/metaparse/example/getting_started/3_2.hpp new file mode 100644 index 000000000..0cc9a48e7 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/3_2.hpp @@ -0,0 +1,14 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_3_2_HPP +#define BOOST_METAPARSE_GETTING_STARTED_3_2_HPP + +// Automatically generated header file + +// Definitions before section 3.1 +#include "3_1.hpp" + +// Definitions of section 3.1 +// query: +// exp_parser1::apply<BOOST_METAPARSE_STRING("thirteen")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/3_3.hpp b/src/boost/libs/metaparse/example/getting_started/3_3.hpp new file mode 100644 index 000000000..cc35183f1 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/3_3.hpp @@ -0,0 +1,24 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_3_3_HPP +#define BOOST_METAPARSE_GETTING_STARTED_3_3_HPP + +// Automatically generated header file + +// Definitions before section 3.2 +#include "3_2.hpp" + +// Definitions of section 3.2 +// query: +// exp_parser1::apply<BOOST_METAPARSE_STRING("11 13")>::type + +#include <boost/metaparse/entire_input.hpp> + +using exp_parser2 = build_parser<entire_input<int_>>; + +// query: +// exp_parser2::apply<BOOST_METAPARSE_STRING("13")>::type + +// query: +// exp_parser2::apply<BOOST_METAPARSE_STRING("11 13")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/4.hpp b/src/boost/libs/metaparse/example/getting_started/4.hpp new file mode 100644 index 000000000..6fe2fc8f6 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/4.hpp @@ -0,0 +1,21 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_4_HPP +#define BOOST_METAPARSE_GETTING_STARTED_4_HPP + +// Automatically generated header file + +// Definitions before section 3.3 +#include "3_3.hpp" + +// Definitions of section 3.3 +// query: +// exp_parser2::apply<BOOST_METAPARSE_STRING("11 ")>::type + +#include <boost/metaparse/token.hpp> + +using exp_parser3 = build_parser<entire_input<token<int_>>>; + +// query: +// exp_parser3::apply<BOOST_METAPARSE_STRING("11 ")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/4_1.hpp b/src/boost/libs/metaparse/example/getting_started/4_1.hpp new file mode 100644 index 000000000..513705947 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/4_1.hpp @@ -0,0 +1,27 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_4_1_HPP +#define BOOST_METAPARSE_GETTING_STARTED_4_1_HPP + +// Automatically generated header file + +// Definitions before section 4 +#include "4.hpp" + +// Definitions of section 4 +#include <boost/metaparse/lit_c.hpp> + +#include <boost/metaparse/sequence.hpp> + +using exp_parser4 = build_parser<sequence<token<int_>, token<lit_c<'+'>>, token<int_>>>; + +// query: +// exp_parser4::apply<BOOST_METAPARSE_STRING("11 + 2")>::type + +#ifdef __METASHELL +#include <metashell/formatter.hpp> +#endif + +// query: +// exp_parser4::apply<BOOST_METAPARSE_STRING("11 + 2")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/4_2.hpp b/src/boost/libs/metaparse/example/getting_started/4_2.hpp new file mode 100644 index 000000000..1663c4686 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/4_2.hpp @@ -0,0 +1,20 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_4_2_HPP +#define BOOST_METAPARSE_GETTING_STARTED_4_2_HPP + +// Automatically generated header file + +// Definitions before section 4.1 +#include "4_1.hpp" + +// Definitions of section 4.1 +using int_token = token<int_>; + +using plus_token = token<lit_c<'+'>>; + +using exp_parser5 = build_parser<sequence<int_token, plus_token, int_token>>; + +// query: +// exp_parser5::apply<BOOST_METAPARSE_STRING("11 + 2")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/5.hpp b/src/boost/libs/metaparse/example/getting_started/5.hpp new file mode 100644 index 000000000..671b34e9e --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/5.hpp @@ -0,0 +1,45 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_5_HPP +#define BOOST_METAPARSE_GETTING_STARTED_5_HPP + +// Automatically generated header file + +// Definitions before section 4.2 +#include "4_2.hpp" + +// Definitions of section 4.2 +#include <boost/metaparse/transform.hpp> + +#include <boost/mpl/plus.hpp> + +#include <boost/mpl/at.hpp> + +template <class Vector> + struct eval_plus : + boost::mpl::plus< + typename boost::mpl::at_c<Vector, 0>::type, + typename boost::mpl::at_c<Vector, 2>::type + > {}; + +// query: +// eval_plus< +// boost::mpl::vector< +// mpl_::integral_c<int, 11>, +// mpl_::char_<'+'>, +// mpl_::integral_c<int, 2> +// >>::type + +#include <boost/mpl/quote.hpp> + +using exp_parser6 = + build_parser< + transform< + sequence<int_token, plus_token, int_token>, + boost::mpl::quote1<eval_plus> + > + >; + +// query: +// exp_parser6::apply<BOOST_METAPARSE_STRING("11 + 2")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/5_1.hpp b/src/boost/libs/metaparse/example/getting_started/5_1.hpp new file mode 100644 index 000000000..4042182e2 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/5_1.hpp @@ -0,0 +1,12 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_5_1_HPP +#define BOOST_METAPARSE_GETTING_STARTED_5_1_HPP + +// Automatically generated header file + +// Definitions before section 5 +#include "5.hpp" + +// Definitions of section 5 + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/5_2.hpp b/src/boost/libs/metaparse/example/getting_started/5_2.hpp new file mode 100644 index 000000000..ea9a0b18a --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/5_2.hpp @@ -0,0 +1,24 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_5_2_HPP +#define BOOST_METAPARSE_GETTING_STARTED_5_2_HPP + +// Automatically generated header file + +// Definitions before section 5.1 +#include "5_1.hpp" + +// Definitions of section 5.1 +#include <boost/metaparse/any.hpp> + +using exp_parser7 = + build_parser< + sequence< + int_token, /* The first <number> */ + repeated<sequence<plus_token, int_token>> /* The "+ <number>" elements */ + > + >; + +// query: +// exp_parser7::apply<BOOST_METAPARSE_STRING("1 + 2 + 3 + 4")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/5_2_1.hpp b/src/boost/libs/metaparse/example/getting_started/5_2_1.hpp new file mode 100644 index 000000000..f8e9ca219 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/5_2_1.hpp @@ -0,0 +1,13 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_5_2_1_HPP +#define BOOST_METAPARSE_GETTING_STARTED_5_2_1_HPP + +// Automatically generated header file + +// Definitions before section 5.2 +#include "5_2.hpp" + +// Definitions of section 5.2 +using temp_result = exp_parser7::apply<BOOST_METAPARSE_STRING("1 + 2 + 3 + 4")>::type; + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/5_2_2.hpp b/src/boost/libs/metaparse/example/getting_started/5_2_2.hpp new file mode 100644 index 000000000..ea9ecb366 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/5_2_2.hpp @@ -0,0 +1,58 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_5_2_2_HPP +#define BOOST_METAPARSE_GETTING_STARTED_5_2_2_HPP + +// Automatically generated header file + +// Definitions before section 5.2.1 +#include "5_2_1.hpp" + +// Definitions of section 5.2.1 +#include <boost/mpl/fold.hpp> + +using vector_of_numbers = + boost::mpl::vector< + boost::mpl::int_<2>, + boost::mpl::int_<5>, + boost::mpl::int_<6> + >; + +template <class Vector> + struct sum_vector : + boost::mpl::fold< + Vector, + boost::mpl::int_<0>, + boost::mpl::lambda< + boost::mpl::plus<boost::mpl::_1, boost::mpl::_2> + >::type + > + {}; + +// query: +// sum_vector<vector_of_numbers>::type + +template <class Sum, class Item> + struct sum_items : + boost::mpl::plus< + Sum, + typename boost::mpl::at_c<Item, 1>::type + > + {}; + +// query: +// sum_items< +// mpl_::integral_c<int, 1>, +// boost::mpl::vector<mpl_::char_<'+'>, mpl_::integral_c<int, 2>> +// >::type + +// query: +// boost::mpl::at_c<temp_result, 1>::type + +// query: +// boost::mpl::fold< +// boost::mpl::at_c<temp_result, 1>::type, /* The vector to summarise */ +// boost::mpl::int_<0>, /* The value to start the sum from */ +// boost::mpl::quote2<sum_items> /* The function to call in each iteration */ +// >::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/5_2_3.hpp b/src/boost/libs/metaparse/example/getting_started/5_2_3.hpp new file mode 100644 index 000000000..b14a0c5e5 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/5_2_3.hpp @@ -0,0 +1,58 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_5_2_3_HPP +#define BOOST_METAPARSE_GETTING_STARTED_5_2_3_HPP + +// Automatically generated header file + +// Definitions before section 5.2.2 +#include "5_2_2.hpp" + +// Definitions of section 5.2.2 +using exp_parser8 = + build_parser< + sequence< + int_token, /* parse the first <number> */ + transform< + repeated<sequence<plus_token, int_token>>, /* parse the "+ <number>" elements */ + /* lambda expression summarising the "+ <number>" elements using fold */ + boost::mpl::lambda< + /* The folding expression we have just created */ + boost::mpl::fold< + boost::mpl::_1, /* the argument of the lambda expression, the result */ + /* of the repeated<...> parser */ + boost::mpl::int_<0>, + boost::mpl::quote2<sum_items> + > + >::type + > + > + >; + +// query: +// exp_parser8::apply<BOOST_METAPARSE_STRING("1 + 2 + 3 + 4")>::type + +using exp_parser9 = + build_parser< + transform< + /* What we had so far */ + sequence< + int_token, + transform< + repeated<sequence<plus_token, int_token>>, + boost::mpl::lambda< + boost::mpl::fold< + boost::mpl::_1, + boost::mpl::int_<0>, + boost::mpl::quote2<sum_items> + > + >::type + > + >, + boost::mpl::quote1<sum_vector> /* summarise the vector of numbers */ + > + >; + +// query: +// exp_parser9::apply<BOOST_METAPARSE_STRING("1 + 2 + 3 + 4")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/5_2_4.hpp b/src/boost/libs/metaparse/example/getting_started/5_2_4.hpp new file mode 100644 index 000000000..3d4d30210 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/5_2_4.hpp @@ -0,0 +1,27 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_5_2_4_HPP +#define BOOST_METAPARSE_GETTING_STARTED_5_2_4_HPP + +// Automatically generated header file + +// Definitions before section 5.2.3 +#include "5_2_3.hpp" + +// Definitions of section 5.2.3 +#include <boost/metaparse/foldl.hpp> + +using exp_parser10 = + build_parser< + transform< + sequence< + int_token, + foldl< + sequence<plus_token, int_token>, + boost::mpl::int_<0>, + boost::mpl::quote2<sum_items> + > + >, + boost::mpl::quote1<sum_vector>> + >; + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/6.hpp b/src/boost/libs/metaparse/example/getting_started/6.hpp new file mode 100644 index 000000000..906cb04bd --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/6.hpp @@ -0,0 +1,25 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_6_HPP +#define BOOST_METAPARSE_GETTING_STARTED_6_HPP + +// Automatically generated header file + +// Definitions before section 5.2.4 +#include "5_2_4.hpp" + +// Definitions of section 5.2.4 +#include <boost/metaparse/foldl_start_with_parser.hpp> + +using exp_parser11 = + build_parser< + foldl_start_with_parser< + sequence<plus_token, int_token>, /* apply this parser repeatedly */ + int_token, /* use this parser to get the initial value */ + boost::mpl::quote2<sum_items> /* use this function to add a new value to the summary */ + > + >; + +// query: +// exp_parser11::apply<BOOST_METAPARSE_STRING("1 + 2 + 3 + 4")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/6_1.hpp b/src/boost/libs/metaparse/example/getting_started/6_1.hpp new file mode 100644 index 000000000..0cc124497 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/6_1.hpp @@ -0,0 +1,12 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_6_1_HPP +#define BOOST_METAPARSE_GETTING_STARTED_6_1_HPP + +// Automatically generated header file + +// Definitions before section 6 +#include "6.hpp" + +// Definitions of section 6 + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/6_2.hpp b/src/boost/libs/metaparse/example/getting_started/6_2.hpp new file mode 100644 index 000000000..d9f8bad27 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/6_2.hpp @@ -0,0 +1,27 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_6_2_HPP +#define BOOST_METAPARSE_GETTING_STARTED_6_2_HPP + +// Automatically generated header file + +// Definitions before section 6.1 +#include "6_1.hpp" + +// Definitions of section 6.1 +using minus_token = token<lit_c<'-'>>; + +#include <boost/metaparse/one_of.hpp> + +using exp_parser12 = + build_parser< + foldl_start_with_parser< + sequence<one_of<plus_token, minus_token>, int_token>, + int_token, + boost::mpl::quote2<sum_items> + > + >; + +// query: +// exp_parser12::apply<BOOST_METAPARSE_STRING("1 + 2 - 3")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/7.hpp b/src/boost/libs/metaparse/example/getting_started/7.hpp new file mode 100644 index 000000000..fe245b98a --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/7.hpp @@ -0,0 +1,49 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_7_HPP +#define BOOST_METAPARSE_GETTING_STARTED_7_HPP + +// Automatically generated header file + +// Definitions before section 6.2 +#include "6_2.hpp" + +// Definitions of section 6.2 +#include <boost/mpl/minus.hpp> + +template <class L, char Op, class R> struct eval_binary_op; + +template <class L, class R> struct eval_binary_op<L, '+', R> : boost::mpl::plus<L, R>::type {}; + +template <class L, class R> struct eval_binary_op<L, '-', R> : boost::mpl::minus<L, R>::type {}; + +// query: +// eval_binary_op<boost::mpl::int_<11>, '+', boost::mpl::int_<2>>::type + +// query: +// eval_binary_op<boost::mpl::int_<13>, '-', boost::mpl::int_<2>>::type + +template <class S, class Item> + struct binary_op : + eval_binary_op< + S, + boost::mpl::at_c<Item, 0>::type::value, + typename boost::mpl::at_c<Item, 1>::type + > + {}; + +// query: +// binary_op<boost::mpl::int_<11>, boost::mpl::vector<boost::mpl::char_<'+'>, boost::mpl::int_<2>>>::type + +using exp_parser13 = + build_parser< + foldl_start_with_parser< + sequence<one_of<plus_token, minus_token>, int_token>, + int_token, + boost::mpl::quote2<binary_op> + > + >; + +// query: +// exp_parser13::apply<BOOST_METAPARSE_STRING("1 + 2 - 3")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/7_1.hpp b/src/boost/libs/metaparse/example/getting_started/7_1.hpp new file mode 100644 index 000000000..02b99e7b6 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/7_1.hpp @@ -0,0 +1,12 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_7_1_HPP +#define BOOST_METAPARSE_GETTING_STARTED_7_1_HPP + +// Automatically generated header file + +// Definitions before section 7 +#include "7.hpp" + +// Definitions of section 7 + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/7_2.hpp b/src/boost/libs/metaparse/example/getting_started/7_2.hpp new file mode 100644 index 000000000..07e1a3583 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/7_2.hpp @@ -0,0 +1,35 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_7_2_HPP +#define BOOST_METAPARSE_GETTING_STARTED_7_2_HPP + +// Automatically generated header file + +// Definitions before section 7.1 +#include "7_1.hpp" + +// Definitions of section 7.1 +#include <boost/mpl/times.hpp> + +template <class L, class R> struct eval_binary_op<L, '*', R> : boost::mpl::times<L, R>::type {}; + +// query: +// eval_binary_op<boost::mpl::int_<3>, '*', boost::mpl::int_<4>>::type + +using times_token = token<lit_c<'*'>>; + +using exp_parser14 = + build_parser< + foldl_start_with_parser< + sequence<one_of<plus_token, minus_token, times_token>, int_token>, + int_token, + boost::mpl::quote2<binary_op> + > + >; + +// query: +// exp_parser14::apply<BOOST_METAPARSE_STRING("2 * 3")>::type + +// query: +// exp_parser14::apply<BOOST_METAPARSE_STRING("1 + 2 * 3")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/8.hpp b/src/boost/libs/metaparse/example/getting_started/8.hpp new file mode 100644 index 000000000..c052f5b83 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/8.hpp @@ -0,0 +1,25 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_8_HPP +#define BOOST_METAPARSE_GETTING_STARTED_8_HPP + +// Automatically generated header file + +// Definitions before section 7.2 +#include "7_2.hpp" + +// Definitions of section 7.2 +using mult_exp1 = foldl_start_with_parser<sequence<times_token, int_token>, int_token, boost::mpl::quote2<binary_op>>; + +using exp_parser15 = + build_parser< + foldl_start_with_parser< + sequence<one_of<plus_token, minus_token>, mult_exp1>, + mult_exp1, + boost::mpl::quote2<binary_op> + > + >; + +// query: +// exp_parser15::apply<BOOST_METAPARSE_STRING("1 + 2 * 3")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/8_1.hpp b/src/boost/libs/metaparse/example/getting_started/8_1.hpp new file mode 100644 index 000000000..aca70e75c --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/8_1.hpp @@ -0,0 +1,36 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_8_1_HPP +#define BOOST_METAPARSE_GETTING_STARTED_8_1_HPP + +// Automatically generated header file + +// Definitions before section 8 +#include "8.hpp" + +// Definitions of section 8 +#include <boost/mpl/divides.hpp> + +template <class L, class R> struct eval_binary_op<L, '/', R> : boost::mpl::divides<L, R>::type {}; + +using divides_token = token<lit_c<'/'>>; + +using mult_exp2 = + foldl_start_with_parser< + sequence<one_of<times_token, divides_token>, int_token>, + int_token, + boost::mpl::quote2<binary_op> + >; + +using exp_parser16 = + build_parser< + foldl_start_with_parser< + sequence<one_of<plus_token, minus_token>, mult_exp2>, + mult_exp2, + boost::mpl::quote2<binary_op> + > + >; + +// query: +// exp_parser16::apply<BOOST_METAPARSE_STRING("8 / 4")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/8_2.hpp b/src/boost/libs/metaparse/example/getting_started/8_2.hpp new file mode 100644 index 000000000..303c38830 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/8_2.hpp @@ -0,0 +1,12 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_8_2_HPP +#define BOOST_METAPARSE_GETTING_STARTED_8_2_HPP + +// Automatically generated header file + +// Definitions before section 8.1 +#include "8_1.hpp" + +// Definitions of section 8.1 + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/9.hpp b/src/boost/libs/metaparse/example/getting_started/9.hpp new file mode 100644 index 000000000..47366b913 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/9.hpp @@ -0,0 +1,42 @@ +#ifndef BOOST_METAPARSE_GETTING_STARTED_9_HPP +#define BOOST_METAPARSE_GETTING_STARTED_9_HPP + +// Automatically generated header file + +// Definitions before section 8.2 +#include "8_2.hpp" + +// Definitions of section 8.2 +template <class S, class Item> + struct reverse_binary_op : + eval_binary_op< + typename boost::mpl::at_c<Item, 0>::type, + boost::mpl::at_c<Item, 1>::type::value, + S + > + {}; + +#include <boost/metaparse/foldr_start_with_parser.hpp> + +using mult_exp3 = + foldr_start_with_parser< + sequence<int_token, one_of<times_token, divides_token>>, /* The parser applied repeatedly */ + int_token, /* The parser parsing the last number */ + boost::mpl::quote2<reverse_binary_op> /* The function called for every result */ + /* of applying the above parser */ + >; + +using exp_parser17 = + build_parser< + foldl_start_with_parser< + sequence<one_of<plus_token, minus_token>, mult_exp3>, + mult_exp3, + boost::mpl::quote2<binary_op> + > + >; + +// query: +// exp_parser17::apply<BOOST_METAPARSE_STRING("8 / 4 / 2")>::type + +#endif + diff --git a/src/boost/libs/metaparse/example/getting_started/README b/src/boost/libs/metaparse/example/getting_started/README new file mode 100644 index 000000000..f2c6703b5 --- /dev/null +++ b/src/boost/libs/metaparse/example/getting_started/README @@ -0,0 +1,6 @@ +This example contains the code snippets of Getting Started. These headers are +intended to be used from Metashell. To get all the definitions before section +N. you need to include N.hpp + +The headers can always be re-generated by running tools/generate_all.py + |