Skip to content

contrib/uri.hpp userinfo #79

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

You must be logged in to vote

First of all: Thank you for the feedback.

There is probably a lot that can be said about how to handle backtracking, but in the end there is no one right way, no one-size-fits-all solution. The problem is that, depending on the grammar, you might have "easy" hacks available to deal with it or not. I'll therefore focus on your specific problem, which is parsing URIs. Since the parser can not know in advance whether the userinfo that just matched will be followed by a @, I'd suggest to simply defer the decision. I've modified the grammar for contrib/uri.hpp, you can use it without the need for a control class like this:

#include <tao/pegtl.hpp>
#include <tao/pegtl/contrib/uri.hpp>

#include <

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
Answer selected by d-frey
Comment options

You must be logged in to vote
0 replies
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 #79 on December 09, 2020 10:25.