Skip to content

How can I return from parsing ahead of time? #342

Closed Answered by ColinH
shuizaiku7 asked this question in Q&A
Discussion options

You must be logged in to vote

Alternatively you could use the tao::pegtl::until rule, increment a counter in the action for each item, and check whether the counters match in a separate action attached to the tao::pegtl::success rule that you use as termination condition for the until. This works if you use a slightly less often used feature, namely that actions can return bool instead of void; if an action returns false then the rule that it is attached to will be considered as not matched, "as if" the rule had returned false itself (though in that case the action wouldn't have been called).

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@ColinH
Comment options

@ColinH
Comment options

@ColinH
Comment options

@shuizaiku7
Comment options

@ColinH
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by ColinH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants