unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#58727: 29.0.50; rx doc: Semantics of RX...
@ 2022-10-23  2:32 Michael Heerdegen
  2022-10-23 16:14 ` Mattias Engdegård
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Heerdegen @ 2022-10-23  2:32 UTC (permalink / raw)
  To: 58727


Hello,

please document the semantics of multiple RXs for the RX repetition
operators (and maybe grouping operators, too).

The resulting regexps are concatenating like with an implicit `seq'.
This is not trivial, though: in stringish regexps the repetition
operators are only unary, and different interpretations would make sense
for `rx' (implicit `seq', implicit `or').

The docstring of `rx' doesn't tell anything about this.  The manual has
sentences like

| ‘(zero-or-more RX...)’
| ‘(0+ RX...)’
|      Match the RXs zero or more times.  Greedy by default.
|      Corresponding string regexp: ‘A*’ (greedy), ‘A*?’ (non-greedy)

but that suffers from the same problem that the semantics of A are not
clear: A == (seq RX...) ?

Oh, and maybe let's also make more clear that `rx' always cares about
implicit grouping when necessary.  For example, in
(info "(elisp) Rx Constructs") it's not trivial that e.g. in

‘(seq RX...)’
‘(sequence RX...)’
‘(: RX...)’
‘(and RX...)’
     Match the RXs in sequence.  Without arguments, the expression
     matches the empty string.
     Corresponding string regexp: ‘AB...’ (subexpressions in sequence).

`rx' silently adds shy grouping to the result, and the corresponding string
regexp in this case is more precisely \(?:AB...\).  I think it is enough
to mention this implicit grouping feature once, but it is important to
spell it out.
  

TIA,

Michael.







^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-25  2:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-23  2:32 bug#58727: 29.0.50; rx doc: Semantics of RX Michael Heerdegen
2022-10-23 16:14 ` Mattias Engdegård
2022-10-24  2:34   ` Michael Heerdegen
2022-10-24 12:49     ` Mattias Engdegård
2022-10-25  2:49       ` Michael Heerdegen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).