@@ -63,18 +63,18 @@ int main(void) {
63
63
parser["Additive"] = [](const SemanticValues& sv) {
64
64
switch (sv.choice()) {
65
65
case 0: // "Multitive '+' Additive"
66
- return sv[0].get <int>() + sv[1].get <int>();
66
+ return any_cast <int>(sv[0] ) + any_cast <int>(sv[1] );
67
67
default: // "Multitive"
68
- return sv[0].get <int>();
68
+ return any_cast <int>(sv[0] );
69
69
}
70
70
};
71
71
72
72
parser["Multitive"] = [](const SemanticValues& sv) {
73
73
switch (sv.choice()) {
74
74
case 0: // "Primary '*' Multitive"
75
- return sv[0].get <int>() * sv[1].get<int>( );
75
+ return any_cast<int>( sv[0]) + any_cast <int>(sv[1]);
76
76
default: // "Primary"
77
- return sv[0].get <int>();
77
+ return any_cast <int>(sv[0] );
78
78
}
79
79
};
80
80
@@ -110,9 +110,9 @@ There are four semantic actions available:
110
110
111
111
` any& dt ` is a 'read-write' context data which can be used for whatever purposes. The initial context data is set in ` peg::parser::parse ` method.
112
112
113
- ` peg::any ` is a simpler implementatin of [ boost ::any] ( http://www.boost.org/doc/libs/1_57_0/doc/html/any.html ) . It can wrap arbitrary data type.
114
- If the compiler in use supports C++17, by default ` peg::any ` is defined as an alias to ` std::any ` .
115
- To force using the simpler ` any ` implementation that comes with ` cpp-peglib ` , define ` PEGLIB_USE_STD_ANY ` as 0 before including ` peglib.h ` :
113
+ ` peg::any ` is a simpler implementatin of std ::any. If the compiler in use supports C++17, by default ` peg::any ` is defined as an alias to ` std::any ` .
114
+
115
+ To force using the simpler ` any ` implementation that comes with ` cpp-peglib ` , define ` PEGLIB_USE_STD_ANY ` as 0 before including ` peglib.h ` :
116
116
``` cpp
117
117
#define PEGLIB_USE_STD_ANY 0
118
118
#include <peglib.h>
0 commit comments