Open lassik opened 4 years ago
It would be nice to have this SRFI, since it's part of R7RS large.
Now, what would be the advantage of re-implementing it with PCRE? Performance only, or something else?
Now, what would be the advantage of re-implementing it with PCRE?
The main thing is that we wouldn't need to have the matcher in Scheme code since PCRE already implements it. We could just translate each S-expression regexp to a string suitable for PCRE. Presumably PCRE is also a lot faster.
Hmm, that sounds really nice! The Scheme with a FAST implementation of SRFI-115. :) :)
@lassik do you want to work on this?
I don't have time to do a full implementation, but I can give pointers.
irregex
is a well-known Scheme library by Alex Shinn, author of Chibi-Scheme. It has been ported to Chicken and probably other Schemes. Among other things, it contains a sre->string
utility that converts (what I believe is) a SRFI 115 SRE (Scheme Regular Expression) into a PCRE string regexp. Here it is:
https://github.com/ashinn/irregex/blob/master/irregex-utils.scm#L84
I suspect it's not very battle-tested, but it's probably the best starting point. In case of problems, the SRFI 115 mailing list can help.
Documentation for the irregex library:
http://snow-fort.org/s/gmail.com/alexshinn/chibi/irregex/0.9.3/index.html
Here's the PCRE library that ships with Chibi-Scheme:
https://github.com/ashinn/chibi-scheme/blob/master/lib/chibi/regexp/pcre.scm
It has a converter in the opposite direction: pcre->sre
.
Alex's code is generally MIT/BSD licensed.
Hi @lassik,
I have implemented SRFI-115 (using the implementation given in the SRFI). I tried to translate the Scheme regexps to PRCE regexps, using the links you provided. I have something for simple regexps, but it doesn't work in the general case. You're right: it would be really cool to have it for STklos; I'll try to finish the implementation later.
https://srfi.schemers.org/srfi-115/srfi-115.html
How hard would this be to implement using PCRE?