14 Ocak 2022 Cuma tarihinde Christoph Anton Mitterer <cales...@scientia.org> yazdı:
> Which is impossible again, especially in a portable manner, when it's > ambiguous what a valid RE is. Except it's not. Use a delimiter that doesn't appear in the RE and you're good. > But since it is neither specified how the parsing is done (left->right > vs. search-for-delimiters-first), nor which rule (literal-in-bracket- > expression vs. not-following-a-backslash) would win over the other. > > In your other posts, you imply that it would be clearly left->right > parsing (which I also don't think is that clear). > > But here you say in contrast, that it would be clearly a "literal" (in > whichever sense) character, when not preceded by \ . But that again > couldn't even be checked with left-to-right parsing. > As soon as the [ is encountered, the parser would be in bracket- > expression-mode. Not sure what you're saying here. The way I understand the standard, context addresses and arguments to the `s' and `y' commands can be delimited using a single routine that finds the next delimiter by following these steps (where `p' is a pointer to the beginning of the string to be delimited): 1. If `*p' is the delimiter or NUL, return `p'. 2. If `*p' is a backslash, and followed by another backslash or the delimiter, increment `p' by one. 3. Increment `p' by one and go to step 1. The delimited string would then be further processed (from left to right) by the caller honoring these rules: * If the string is one of the arguments to a `y' command, `\n' represents a newline regardless of the delimiter character; and a backslash followed by another backslash or the delimiter represents a single backslash or the delimiter character, respectively. * If the string is the replacement part of an `s' command, `\&' represents a literal ampersand, not the special one, regardless of the delimiter character; and a backslash followed by another backslash or the delimiter, again, represents a single backslash or the delimiter character, respectively. * If the string is a context address or the RE part of an `s' command: - Outside a bracket expression, a backslash followed by another backslash or the delimiter represents a single backslash or the delimiter character, respectively. If the delimiter is a special character (either on its own or when preceded by a backslash), it loses its special properties in this RE. For example, if the delimiter is `[', there can't be a bracket expression in this RE. A comma is also special between `\{' and `\}', so `x\{1\,2\}' may be an invalid RE when the delimiter is `,'. - Inside a bracket expression, a backslash followed by the delimiter represents the delimiter character. If the delimiter is one of `-', `.', `:', and `=', it can'T be used for forming a character range, a collating symbol, a character class, or an equivalence class, respectively. I'm NOT saying anyone does it this way nor should. What I'm saying is that the standard reads like doing it this way is fine.