some clarification on sre syntax Duy Nguyen (19 Jul 2019 08:57 UTC)
Re: some clarification on sre syntax John Cowan (19 Jul 2019 17:16 UTC)
Re: some clarification on sre syntax Duy Nguyen (20 Jul 2019 00:52 UTC)

some clarification on sre syntax Duy Nguyen 19 Jul 2019 08:56 UTC

I'm trying to implement SRE in Gauche Scheme and have a few questions

In the srfi examples, 'digit' is used as a named character set, but
it's not documented (only num and numeric are). Chibi seems to
recognize 'digit' as well. Is it a real charset, or do we need to
update the examples?

Many sre forms accept multiple <sre> but it's not exactly clear how to
interpret it. For example, what does (submatch <sre-1> <sre-2>) mean?
I suppose it's the same as (submatch (seq <sre-1> <sre-2>)) though I'm
not sure if that's intended.

It's even worse with w/case and w/nocase, if it's used in <cset-sre>
context, e.g. (and ascii (w/nocase #\a #\b)), does that produce
"[AaBb]"? But then it's confusing because I suppose (w/nocase "abc"
"def") is equivalent to "[AaBbCc][DdEeFf]"? I think Chibi scheme
handles (w/nocase #\a #\b) like (w/nocase #\a), which makes sense
because it removes ambiguation. But then we probably should remove the
"..." part in the document.

(~ sre1 sre2 sre3) could use some elaboration too. It briefly mentions
"complement _of union_" in the syntax summary. (- sre1 sre2 sre3)
follows the same "of union" rule according to chibi scheme, though it
feels weird because (- 1 2 3) is (- (- 1 2) 3) not (- 1 (+ 2 3)).
--
Duy