1 | #include <boost/proto/proto.hpp>
|
---|
2 |
|
---|
3 | namespace proto = boost::proto;
|
---|
4 |
|
---|
5 | struct start_type {};
|
---|
6 |
|
---|
7 | struct element_grammar:
|
---|
8 | proto::or_<
|
---|
9 | proto::terminal<char[proto::N]>
|
---|
10 |
|
---|
11 | /* Replacing 1 with 0 makes the compilation error disappear. */
|
---|
12 | #if 0
|
---|
13 | ,
|
---|
14 | proto::terminal<wchar_t[proto::N]>
|
---|
15 | #endif
|
---|
16 | >
|
---|
17 | {};
|
---|
18 |
|
---|
19 | struct grammar:
|
---|
20 | proto::or_<
|
---|
21 | element_grammar,
|
---|
22 | proto::terminal<start_type>,
|
---|
23 | proto::divides<grammar, grammar>
|
---|
24 | >
|
---|
25 | {};
|
---|
26 |
|
---|
27 | template<class Expr>
|
---|
28 | struct expression;
|
---|
29 |
|
---|
30 | struct domain:
|
---|
31 | proto::domain<proto::generator<expression>, grammar>
|
---|
32 | {};
|
---|
33 |
|
---|
34 | template<class Expr>
|
---|
35 | struct expression:
|
---|
36 | proto::extends<Expr, expression<Expr>, domain>
|
---|
37 | {
|
---|
38 | typedef expression<Expr> this_type;
|
---|
39 |
|
---|
40 | typedef
|
---|
41 | proto::extends<Expr, this_type, domain>
|
---|
42 | base_type;
|
---|
43 |
|
---|
44 | expression(const Expr &expr = Expr()):
|
---|
45 | base_type(expr)
|
---|
46 | {}
|
---|
47 |
|
---|
48 | };
|
---|
49 |
|
---|
50 | expression<proto::terminal<start_type>::type> start;
|
---|
51 |
|
---|
52 | int main(int argc, char** argv) {
|
---|
53 | auto expr = start / "123";
|
---|
54 | }
|
---|