The recursion I vaguely had in mind was
my $escape;
$escape = qr/(?<!(??{ $escape}))\\/;
It fails, of course, because it would require variable-length lookbehind.
Anno | [reply] [d/l] |
Parsers can't do lookbehind, not to mention recursive lookbehind. You're straying way off your point (that this is a parser problem, not a regexp problem) by saying variable-length lookbehind is required.
Besides, you said "The recognition of escaped escapes is a naturally recursive problem." There's nothing recursive about "Count the number of slashes leading up to the char. If the count is odd, the character is escaped. If the count is even, the character is not escaped."
| [reply] |
The definition would have to be: A backslash is escaped if it preceded by an unescaped backslash. Implementing that directly leads to recursion. It takes an analysis of the definition to arrive at the the odd-even rule and a simpler implementation.
Anno
| [reply] |