Closed beckyjackson closed 3 years ago
Looks good.
I think we only want the s
operator. If we require that, then that would distinguish the trailing slash case from an empty substitution. Do you want to do it that way?
Yes! That perfectly solves the problem 😄
This allows regex expressions in Perl format to be used in functions:
... and
The operator & flags are optional. The delimiter is always a forward slash.
I had to do some hacky things to allow escaped forward slashes to be used within the patterns and replacements, but it seems to work for all cases.
I wanted to just use negative lookbehind, but Nearley doesn't allow that.
There are two problems with this currently. The first one I think we can work around:
pat\/ern
becomespat\\/ern
. I tried doing a replace, but I think this is actually happening when it gets printed out. We should test this in Python and see if it only includes the one escape character.@jamesaoverton could you let me know what you think? Currently we have some regex stuff in
valve.py
that I just parse in Python, but I think it would be cool to do this in the grammar.