feature: variable substitution - #14
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
paurkedal
left a comment
There was a problem hiding this comment.
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
%pcreextension.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.0has breaking changes in the Parsetree AST.