SRE regular expression syntax
Looking for eggs that handle regular expressions, I found scsh-regexp. It implements most of the regexp API, as described in "Proposed SRE regular-expression notation".
Now, I'm not particularly interested in the API, as Chicken already supports regular expressions out of the box (see the regex unit). What I find much more interesting is the part of the proposal that *isn't* implemented. It also defines a syntax for describing regular expressions. This part isn't available in the egg; according to scsh-regexp's documentation, it was only implemented in SCSH.
Many questions arise. Why wasn't this implemented elsewhere? Would it be useful (i.e. compared to usual regex notation)? Would it be hard to port to Chicken? Would it be hard to write from scratch, going by the documentation only?
Most likely, I'm not up to the task, but that doesn't stop me from dreaming about things like a sed-like stream editor using this kind of syntax for regular expressions. It would be super verbose, but also more readable... at least, that is the assumption.
creidiki said,
February 8, 2008 @ 4:31 pm
I've been wondering that myself. We use guile for our scheme init scripts, and the (ice-9 regex) module also implements the API but not the syntax.
Its not like it would be slower running regexps defined that way, you have to compile them anyway if you intend to use them with any decent speed... perhaps just lack of developer time :)
John Cowan said,
February 8, 2008 @ 4:48 pm
I like S-expression regular expressions very much. It wouldn't be at all hard to port them to Chicken or even rewrite them from scratch, as all they do is process the S-expression and return a string containing the equivalent PCRE, being sure to do all the escaping that's needed.
Graham Fawcett said,
February 15, 2008 @ 11:48 pm
You might also be interested in Regular-Tree expressions. RT expressions are like regexes for matching sexprs, rather than matching strings.
http://library.readscheme.org/servlets/cite.ss?pattern=sw2004-bagrak
If I'm not mistaken, Olin Shivers, one of the principal authors, also designed the SRE syntax.