Skip to content

Capturing nested comments #155

Answered by foonathan
DiKetarogg asked this question in Q&A
Jun 26, 2023 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

Your issue is that you use dsl::token inside the dsl::capture. You can then no longer use recursion at all for technical reasons.

You can avoid that by using the second overload of dsl::capture which takes a token production: https://lexy.foonathan.net/playground/?id=5oeabd1ob&mode=tree

Note that multiline and single do not produce values on their own, only the final comment will produce a span that contains the entire comment. I'm assuming this is the semantic you wanted? I'm not sure how you want to capture nested comments otherwise.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@DiKetarogg
Comment options

@foonathan
Comment options

@DiKetarogg
Comment options

@foonathan
Comment options

Answer selected by DiKetarogg
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