Skip to content

Joining Repetion of Rule into One #200

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

You must be logged in to vote

There are multiple ways to achieve what you are looking for, but I can't decide which one is best for you. The fundamental problem, however, is that by default the PEGTL actions as well as the parse tree nodes only reference portions of the input. If the input contains foo\"bar, we can not reference the string foo"bar. You'll have to assemble it yourself or use a convenience helper.

That said, you mentioned that you are working with a parse tree. So here's a small example I wrote which also makes use of only selecting the nodes you are actually interested in and omitting the intermediate nodes:

#include <iostream>
#include <string>

#include <tao/pegtl.hpp>
#include <tao/pegtl/contrib/par…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
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
3 participants
Converted from issue

This discussion was converted from issue #200 on December 09, 2020 08:20.