News for hackers. Stuff that matters.
Re:Show HN: Transductive regular expressions for text editing by twiss on Friday February 07, 2025 @02:07PM (#42976249)
Yeah. Similarly, for the range transformations, instead of `[a:A-z:Z]`, I would suggest `[a-z:A-Z]`; and instead of `[a:b-y:zz:a]`, something like `[a-y:b-z;z:a]`, perhaps.
Re:Show HN: Transductive regular expressions for text editing by kazinator on Friday February 07, 2025 @02:21PM (#42976404)
I would suggest simply [a-z]:[A-Z], inspired by tr.

Then there is no syntactic special case. This is just EXPR:EXPR; the special case is that both EXPR are character class syntax, and so the tr-like range mapping applies.

Re:Show HN: Transductive regular expressions for text editing by c0nstantine on Saturday February 08, 2025 @02:28AM (#42981181)
[a-z] is equivalent to 'a|b|...|z' in the normal regex language.

So if we do [a-z]:[A-Z] it should be expanded to:

(a|b|...|z):(A|B|...|Z)

which is pretty legal in trre but has different meaning of mapping any a-z to ALL the A-Z (generating A-Z on each occurrence of lowercase letter).

Re:Show HN: Transductive regular expressions for text editing by kazinator on Saturday February 08, 2025 @02:50AM (#42981272)
[a-z] is a semantically equivalent regex to a|b|..|z, but the two are not equivalent syntactic forms.

Distinct syntactic forms can be given distinct semantics, as long as there is rhyme and reason.

Moreover, the right side of the colon is not the normal regex language, it only borrows its syntax. So there, we may be justified in denying that the usual equivalence holds between character class syntax and a disjunction of the symbols denoted by the class.

Re:Show HN: Transductive regular expressions for text editing by c0nstantine on Saturday February 08, 2025 @05:59AM (#42982090)
The right side is a normal regex language syntactically. Semantically it is a generator instead of a parser (consumer).

But I got your point. Maybe there could be some ways to do it in consistent way. Just straight tr-like syntax won't work, e.g I really want it something like this to be valid:

[a-b]:(x|y) (pairs a:x, b:x, a:y, b:y)

and I prefer not handle these in some ad-hoc way.

Re:Show HN: Transductive regular expressions for text editing by kazinator on Saturday February 08, 2025 @01:53PM (#42985189)
I also go your point. The right side is a regular expression because it denotes a regular set.