Need help understanding why actions don't [always] trigger #274
-
Considering this test case:
When I run it, I get that the input is parsed correctly, but the output is this:
So I am missing the unsigned integer "2" on the first line, and the identifier "oz" on the second line. I have tried creating the parse tree, and the nodes are missing as well. What am I doing wrong? Thank you! PS: I am using PEGTL 3.2.1, compiled with Clang13 on Linux, in both C++17 and C++20 modes. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 17 replies
-
This is due to the pegtl::seq< rule0, sep, rule1, sep, rule2, sep, ... > whereas in fact, it generates pegtl::seq< rule0, sep, interleaved< rule1, rule2, ... > > and now your specializations for the actions don't match anymore. You need a different approach, something like: // Template to generate rule
// tao::pegtl::seq<Rule0, Separator, Rule1, Separator, Rule2, ... , Separator, RuleN>
template< typename Result, typename Separator, typename... Rules >
struct InterleavedImpl;
template< typename... Results, typename Separator, typename Rule0, typename... RulesRest >
struct InterleavedImpl< pegtl::seq< Results... >, Separator, Rule0, RulesRest... >
: InterleavedImpl< pegtl::seq< Results..., Rule0, Sep >, Separator, RulesRest... >
{};
template< typename... Results, typename Separator, typename Rule0 >
struct InterleavedImpl< pegtl::seq< Results... >, Separator, Rule0 >
{
using type = pegtl::seq< Results..., Rule0 >;
};
template< typename Separator, typename... Rules >
using Interleaved = typename InterleavedImpl< pegtl::seq<>, Separator, Rules... >::type; |
Beta Was this translation helpful? Give feedback.
-
Hi @d-frey - what is a timeline for the next [point] release? I'd like to make use of this new contrib class, but we're trying to stick to official releases. Is this worthy enough of a 3.2.2, and is HEAD stable enough? Thank you, |
Beta Was this translation helpful? Give feedback.
-
We will do a final point release before migrating the license, but we need to clean up some details and adjust the documentation. Due to lack of time, it looks like we will need about 2-3 weeks. |
Beta Was this translation helpful? Give feedback.
This is due to the
Interleaved
-helper not actually generating the type you think it does. You comment suggests it generateswhereas in fact, it generates
and now your specializations for the actions don't match anymore.
You need a different approach, something like: