Skip to content

How to use the state< S, R... > metarule. #9

Answered by d-frey
tylercecil asked this question in Q&A
Discussion options

You must be logged in to vote

You can have a look at the Switching-Style documentation page, there we also mention pegtl/contrib/raw_string.hh as an example.

In the example, you can also find the basic signature for both the constructor as well as the success() method:

template< typename Input, typename ... States >
raw_string_state( const Input &, States && ... )
{ }

template< typename Input, typename ... States >
void success( const Input &, States && ... ) const
{ }

This applies if you want to basically ignore all the (outer) states (which might as well be no states). In most cases, however, you want to apply the collected data of your state class to the outer state.

Is this sufficient? (We might want to extend t…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by d-frey
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #9 on December 09, 2020 11:06.