-
Notifications
You must be signed in to change notification settings - Fork 3
feature: variable substitution #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
If I understand correctly, this is similar to the |
Sure thing, I'll change the syntax! |
Nice addition, one I recall this was on my wish-list if I had spent more time on it.
Shouldn't that, without |
f4d6a69
to
603c634
Compare
You're right, I fixed the symptom and not the cause 😅. The latest commit is an intermediate to a final version, there are still some improvements to be made. I went back and looked at how Important change: the AST is now translated into base |
b12c891
to
c1b28cd
Compare
Nice! We should maybe merge this first to avoid conflicts. There seems to be a bug, though, involving group indexing:
|
Much thanks for catching this! Planning to update the branch this week and fix this issue. |
c1b28cd
to
04a2220
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the two corrections, can you add a test case to cover the three cases of new syntax?
04a2220
to
956170f
Compare
956170f
to
3bf1758
Compare
Related to #12
This PR adds variable substitution to the
%pcre
extension.Details
Allows defining variables with
let%pcre
, which could then be used inside a few patterns for substitution:(?&var)
- Named substitution (doesn't capture)(?&name:var)
- Named substitution with renameOnly 1 AST pass is needed.
If a user tries to definelet%pcre var = (?N<var>)
, the ppx is smart enough to warn the user about having unbounded recursion.Note
This updates the opam package to use
ppxlib <= "0.35.0"
only, asppxlib.0.36.0
has breaking changes in the Parsetree AST.