Is it possible to access what a positive assertion matches? #373
Unanswered
mojavelinux
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Yes, that should be possible. Actually, it was possible but changed in one of linked PRs of this in the original repo, which was the wrong decision. |
Beta Was this translation helpful? Give feedback.
1 reply
-
I'm worried about backward-compatibility. What if we used Do you have an example where it would be useful for |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When I use a positive assertion in a rule, I sometimes need to access the input matched by the assertion in order to store that information in the AST. Is it possible to access what was matched by a positive assertion by assigning it to a label or marking it with
@
. In other words, can I do this? (noticemarker:&(...)
)I can see in the generated parser that there's a point in the rule function where the match is stored in a local variable. But that variable never gets passed to the action for the rule.
I'm trying to understand if I'm doing something incorrectly or if this is not something that peggy (and PEG in general) supports. Any insight would be appreciated.
I know there are other ways to get the information matched by the positive assertion since the input will eventually be consumed. However, it makes the grammar more complex and harder to understand. It seems to me like it should be possible to capture input that has already been found, even if by an assertion.
Beta Was this translation helpful? Give feedback.
All reactions